@@ -285,6 +285,8 @@ for system testing, as shown in [this
285285example] ( https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/localtesting/datastore_test.py ) .
286286* All tests should be independent of one another and order-independent.
287287* 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.
288290
289291### Arrange, Act, Assert
290292
@@ -320,10 +322,22 @@ that embodies assumptions about the behavior of the APIs.
320322When tests need temporary resources (such as a temp file or folder), they
321323should create reasonable names for these resources with a UUID attached to
322324assure 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:
324326
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.
327341
328342### Console Output
329343
@@ -342,7 +356,7 @@ including the flake8 linter, Python 2.7, Python 3.x, and App Engine tests,
342356as well as automated README generation.
343357
344358__ 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
346360order to simulate this locally, you need to copy + rename the parent
347361` noxfile-template.py ` as ` noxfile.py ` in the folder of the project you want to
348362run tests.
0 commit comments