28
28
TEST_PATH Path to package containing test modules"""
29
29
30
30
31
+ def append_or_insert_path (path ):
32
+ """Adds GAE path to system path, or appends it to the google path
33
+ if that already exists."""
34
+ try :
35
+ import google
36
+ google .__path__ .append ("{0}/google" .format (path ))
37
+ except ImportError :
38
+ sys .path .insert (0 , path )
39
+
40
+
31
41
def main (sdk_path , test_path ):
32
42
# If the sdk path points to a google cloud sdk installation
33
43
# then we should alter it to point to the GAE platform location.
44
+
34
45
if os .path .exists (os .path .join (sdk_path , 'platform/google_appengine' )):
35
- sys .path .insert (0 , os .path .join (sdk_path , 'platform/google_appengine' ))
46
+ append_or_insert_path (
47
+ os .path .join (sdk_path , 'platform/google_appengine' ))
36
48
else :
37
- sys . path . insert ( 0 , sdk_path )
49
+ append_or_insert_path ( sdk_path )
38
50
39
51
# Ensure that the google.appengine.* packages are available
40
52
# in tests as well as all bundled third-party packages.
@@ -51,7 +63,7 @@ def main(sdk_path, test_path):
51
63
print "Note: unable to import appengine_config."
52
64
53
65
# Discover and run tests.
54
- suite = unittest .loader .TestLoader ().discover (test_path )
66
+ suite = unittest .loader .TestLoader ().discover (test_path , "*_test.py" )
55
67
unittest .TextTestRunner (verbosity = 2 ).run (suite )
56
68
57
69
0 commit comments