Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(285)

Side by Side Diff: appengine/isolate/tests/test_env.py

Issue 212520043: Reduce code duplication in multiple copies of test_env.py. Base URL: https://code.google.com/p/swarming@1_move
Patch Set: Created 10 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/isolate/tests/handlers_api_test.py ('k') | appengine/isolate/tests/test_support » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Swarming Authors. All rights reserved. 1 # Copyright 2013 The Swarming Authors. All rights reserved.
2 # Use of this source code is governed by the Apache v2.0 license that can be 2 # Use of this source code is governed by the Apache v2.0 license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import sys 6 import sys
7 7
8 # isolate/ 8 # isolate/
9 APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 9 APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10 # components/ (NOT isolate/components/).
11 COMPONENTS_DIR = os.path.join(os.path.dirname(APP_DIR), 'components')
12
13 _INITIALIZED = False
14 10
15 11
16 def setup_test_env(): 12 def setup_test_env():
17 """Sets up App Engine test environment.""" 13 """Sets up App Engine test environment."""
18 global _INITIALIZED
19 if _INITIALIZED:
20 raise Exception('Do not call test_env.setup_test_env() twice.')
21 _INITIALIZED = True
22
23 # For 'from test_support import ...'
24 sys.path.insert(0, COMPONENTS_DIR)
25 # For dependencies of support code.
26 sys.path.insert(0, os.path.join(COMPONENTS_DIR, 'third_party'))
27
28 # For unit tests not importing main.py, which should be ALL unit tests.
29 sys.path.insert(0, os.path.join(APP_DIR, 'components', 'third_party'))
30 # For dependencies of app itself. 14 # For dependencies of app itself.
31 sys.path.insert(0, os.path.join(APP_DIR, 'third_party')) 15 sys.path.insert(0, os.path.join(APP_DIR, 'third_party'))
32 # For application modules. 16 # For application modules.
33 sys.path.insert(0, APP_DIR) 17 sys.path.insert(0, APP_DIR)
34 18
35 from test_support import gae_sdk_utils 19 from test_support import test_env
36 gae_sdk_dir = gae_sdk_utils.find_gae_sdk() 20 test_env.setup_test_env()
37 if not gae_sdk_dir:
38 raise Exception('Unable to find gae sdk path, aborting test.')
39
40 gae_sdk_utils.setup_gae_sdk(gae_sdk_dir)
41 gae_sdk_utils.setup_env(APP_DIR, None, None, None)
OLDNEW
« no previous file with comments | « appengine/isolate/tests/handlers_api_test.py ('k') | appengine/isolate/tests/test_support » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b