3232from system_tests .system_test_utils import EmulatorCreds
3333
3434
35- # Isolated namespace so concurrent test runs don't collide.
36- TEST_NAMESPACE = 'ns%d' % (1000 * time .time (),)
37- EMULATOR_DATASET = os .getenv (GCD_DATASET )
38-
39-
4035class Config (object ):
4136 """Run-time configuration to be modified at set-up.
4237
@@ -56,14 +51,17 @@ def clone_client(client):
5651
5752
5853def setUpModule ():
59- if EMULATOR_DATASET is None :
54+ emulator_dataset = os .getenv (GCD_DATASET )
55+ # Isolated namespace so concurrent test runs don't collide.
56+ test_namespace = 'ns%d' % (1000 * time .time (),)
57+ if emulator_dataset is None :
6058 client_mod .DATASET = TESTS_DATASET
61- Config .CLIENT = datastore .Client (namespace = TEST_NAMESPACE )
59+ Config .CLIENT = datastore .Client (namespace = test_namespace )
6260 else :
6361 credentials = EmulatorCreds ()
6462 http = httplib2 .Http () # Un-authorized.
65- Config .CLIENT = datastore .Client (project = EMULATOR_DATASET ,
66- namespace = TEST_NAMESPACE ,
63+ Config .CLIENT = datastore .Client (project = emulator_dataset ,
64+ namespace = test_namespace ,
6765 credentials = credentials ,
6866 http = http )
6967
@@ -209,11 +207,11 @@ def setUpClass(cls):
209207 cls .CLIENT = clone_client (Config .CLIENT )
210208 # Remove the namespace from the cloned client, since these
211209 # query tests rely on the entities to be already stored and indexed,
212- # hence ``TEST_NAMESPACE `` set at runtime can't be used.
210+ # hence ``test_namespace `` set at runtime can't be used.
213211 cls .CLIENT .namespace = None
214212
215213 # In the emulator, re-populating the datastore is cheap.
216- if EMULATOR_DATASET is not None :
214+ if os . getenv ( GCD_DATASET ) is not None :
217215 # Populate the datastore with the cloned client.
218216 populate_datastore .add_characters (client = cls .CLIENT )
219217
@@ -224,7 +222,7 @@ def setUpClass(cls):
224222 @classmethod
225223 def tearDownClass (cls ):
226224 # In the emulator, destroy the query entities.
227- if EMULATOR_DATASET is not None :
225+ if os . getenv ( GCD_DATASET ) is not None :
228226 # Use the client for this test instead of the global.
229227 clear_datastore .remove_all_entities (client = cls .CLIENT )
230228
0 commit comments