@@ -285,6 +285,8 @@ for system testing, as shown in [this
285
285
example] ( https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/localtesting/datastore_test.py ) .
286
286
* All tests should be independent of one another and order-independent.
287
287
* We use parallel processing for tests, so tests should be capable of running in parallel with one another.
288
+ * Use pytest's fixture for resource setup and teardown, instead of
289
+ having them in the test itself.
288
290
289
291
### Arrange, Act, Assert
290
292
@@ -320,10 +322,22 @@ that embodies assumptions about the behavior of the APIs.
320
322
When tests need temporary resources (such as a temp file or folder), they
321
323
should create reasonable names for these resources with a UUID attached to
322
324
assure uniqueness. Use the Python ``` uuid ``` package from the standard
323
- library to generate UUIDs for resource names.
325
+ library to generate UUIDs for resource names. For example:
324
326
325
- All temporary resources should be explicitly deleted when
326
- testing is complete.
327
+ ``` python
328
+ glossary_id = ' test-glossary-{} ' .format(uuid.uuid4())
329
+ ```
330
+
331
+ or:
332
+
333
+ ``` python
334
+ # If full uuid4 is too long, use hex representation.
335
+ encrypted_disk_name = ' test-disk-{} ' .format(uuid.uuid4().hex)
336
+ ```
337
+
338
+ All temporary resources should be explicitly deleted when testing is
339
+ complete. Use pytest's fixture for cleaning up these resouces instead
340
+ of doing it in test itself.
327
341
328
342
### Console Output
329
343
@@ -342,7 +356,7 @@ including the flake8 linter, Python 2.7, Python 3.x, and App Engine tests,
342
356
as well as automated README generation.
343
357
344
358
__ Note:__ As a temporary workaround, each project currently uses first
345
- ` noxfile-template.py ` found in a parent folder above the current sample. In
359
+ ` noxfile-template.py ` found in a parent folder above the current sample. In
346
360
order to simulate this locally, you need to copy + rename the parent
347
361
` noxfile-template.py ` as ` noxfile.py ` in the folder of the project you want to
348
362
run tests.
0 commit comments