@@ -428,7 +428,51 @@ def test_resource():
428
428
...
429
429
```
430
430
431
- # ## Running tests
431
+ # ## Test Environment Setup
432
+
433
+ Because all tests are system tests that use live resources, running tests
434
+ requires a Google Cloud project with billing enabled, as covered under
435
+ [Creating and Managing Projects](https:// cloud.google.com/ resource- manager/ docs/ creating- managing- projects).
436
+
437
+ Once you have your project created and configured, you' ll need to set
438
+ environment variables to identify the project and resources to be used
439
+ by tests. See
440
+ [testing/ test- env.tmpl.sh](https:// github.com/ GoogleCloudPlatform/ python- docs- samples/ blob/ master/ testing/ test- env.tmpl.sh)
441
+ for a list of all environment variables used by all tests. Not every
442
+ test needs all of these variables. All required environment variables
443
+ should be listed in the README and `testing/ test- env.tmpl.sh` . If you
444
+ find one is missing, please add instructions for setting it as part of
445
+ your PR .
446
+
447
+ We suggest that you copy this file as follows:
448
+
449
+ ```sh
450
+ $ cp testing/ test- env.tmpl.sh testing/ test- env.sh
451
+ $ editor testing/ test- env.sh # change the value of `GCLOUD_PROJECT`.
452
+ ```
453
+
454
+ You can easily `source` this file for exporting the environment variables.
455
+
456
+ # ### Development environment setup
457
+
458
+ This repository supports two ways to run tests locally.
459
+
460
+ 1 . nox
461
+
462
+ This is the recommended way. Setup takes little more efforts than
463
+ the second one, but the test execution will be faster.
464
+
465
+ 2 . Docker
466
+
467
+ This is another way of running the tests. Setup is easier because
468
+ you only need to instal Docker. The test execution will be bit
469
+ slower than the first one.
470
+
471
+ # ### nox setup
472
+
473
+ Please read the [MAC Setup Guide](https:// github.com/ GoogleCloudPlatform/ python- docs- samples/ blob/ master/ MAC_SETUP .md).
474
+
475
+ # ## Running tests with nox
432
476
433
477
Automated testing for samples in `python- docs- samples` is managed by
434
478
[nox](https:// nox.readthedocs.io). Nox allows us to run a variety of tests,
@@ -467,17 +511,23 @@ To run a specific test from a specific following:
467
511
nox - s py- 3.7 -- snippets_test.py:test_list_blobs
468
512
```
469
513
470
- # ## Test Environment Setup
514
+ # ## Running tests with Docker
471
515
472
- Because all tests are system tests that use live resources, running tests
473
- requires a Google Cloud project with billing enabled, as covered under
474
- [Creating and Managing Projects](https:// cloud.google.com/ resource- manager/ docs/ creating- managing- projects).
516
+ If you have [Docker](https:// www.docker.com) installed and runnable by
517
+ the local user, you can use `scripts/ run_tests_local.sh` helper script
518
+ to run the tests. For example, let' s say you want to modify the code
519
+ in `cdn` directory, then you can do:
475
520
476
- Once you have your project created and configured, you' ll need to set environment
477
- variables to identify the project and resources to be used by tests. See
478
- [testing/ test- env.tmpl.sh](https:// github.com/ GoogleCloudPlatform/ python- docs- samples/ blob/ master/ testing/ test- env.tmpl.sh)
479
- for a list of all environment variables used by all tests. Not every test
480
- needs all of these variables.
521
+ ```sh
522
+ $ cd cdn
523
+ $ ../ scripts/ run_tests_local.sh .
524
+ # This will run the default sessions; lint, py-3.6, and py-3.7
525
+ $ ../ scripts/ run_tests_local.sh . lint
526
+ # Running only lint
527
+ ```
528
+
529
+ If your test needs a service account, you have to create a service
530
+ account and download the JSON key to `testing/ service- account.json` .
481
531
482
532
# ## Google Cloud Storage Resources
483
533
0 commit comments