|
16 | 16 |
|
17 | 17 | import os
|
18 | 18 | from pathlib import Path
|
| 19 | +import sys |
19 | 20 |
|
20 | 21 | import nox
|
21 | 22 | import tempfile
|
22 | 23 |
|
23 | 24 |
|
| 25 | +# WARNING - WARNING - WARNING - WARNING - WARNING |
| 26 | +# WARNING - WARNING - WARNING - WARNING - WARNING |
| 27 | +# DO NOT EDIT THIS FILE EVER! |
| 28 | +# WARNING - WARNING - WARNING - WARNING - WARNING |
| 29 | +# WARNING - WARNING - WARNING - WARNING - WARNING |
| 30 | + |
| 31 | +# Copy `noxfile_config.py` to your directory and modify it instead. |
| 32 | + |
| 33 | +# `TEST_CONFIG` dict is a configuration hook that allows users to |
| 34 | +# modify the test configurations. The values here should be in sync |
| 35 | +# with `noxfile_config.py`. Users will copy `noxfile_config.py` into |
| 36 | +# their directory and modify it. |
| 37 | + |
| 38 | +TEST_CONFIG = { |
| 39 | + # You can opt out from the test for specific Python versions. |
| 40 | + 'ignored_versions': ["2.7"], |
| 41 | + |
| 42 | + # An envvar key for determining the project id to use. Change it |
| 43 | + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a |
| 44 | + # build specific Cloud project. You can also use your own string |
| 45 | + # to use your own Cloud project. |
| 46 | + 'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT', |
| 47 | + # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', |
| 48 | + |
| 49 | + # A dictionary you want to inject into your test. Don't put any |
| 50 | + # secrets here. These values will override predefined values. |
| 51 | + 'envs': {}, |
| 52 | +} |
| 53 | + |
| 54 | + |
| 55 | +try: |
| 56 | + # Ensure we can import noxfile_config in the project's directory. |
| 57 | + sys.path.append('.') |
| 58 | + from noxfile_config import TEST_CONFIG_OVERRIDE |
| 59 | +except ImportError as e: |
| 60 | + print("No user noxfile_config found: detail: {}".format(e)) |
| 61 | + TEST_CONFIG_OVERRIDE = {} |
| 62 | + |
| 63 | +# Update the TEST_CONFIG with the user supplied values. |
| 64 | +TEST_CONFIG.update(TEST_CONFIG_OVERRIDE) |
| 65 | + |
| 66 | + |
| 67 | +def get_pytest_env_vars(): |
| 68 | + """Returns a dict for pytest invocation.""" |
| 69 | + ret = {} |
| 70 | + |
| 71 | + # Override the GCLOUD_PROJECT and the alias. |
| 72 | + env_key = TEST_CONFIG['gcloud_project_env'] |
| 73 | + # This should error out if not set. |
| 74 | + ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key] |
| 75 | + ret['GCLOUD_PROJECT'] = os.environ[env_key] # deprecated |
| 76 | + |
| 77 | + # Apply user supplied envs. |
| 78 | + ret.update(TEST_CONFIG['envs']) |
| 79 | + return ret |
| 80 | + |
| 81 | + |
24 | 82 | # DO NOT EDIT - automatically generated.
|
25 | 83 | # All versions used to tested samples.
|
26 | 84 | ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8"]
|
|
30 | 88 |
|
31 | 89 | TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])
|
32 | 90 |
|
| 91 | +INSTALL_LIBRARY_FROM_SOURCE = bool(os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False)) |
33 | 92 | #
|
34 | 93 | # Style Checks
|
35 | 94 | #
|
@@ -104,7 +163,8 @@ def _session_tests(session, post_install=None):
|
104 | 163 | # Pytest will return 5 when no tests are collected. This can happen
|
105 | 164 | # on travis where slow and flaky tests are excluded.
|
106 | 165 | # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
|
107 |
| - success_codes=[0, 5] |
| 166 | + success_codes=[0, 5], |
| 167 | + env=get_pytest_env_vars() |
108 | 168 | )
|
109 | 169 |
|
110 | 170 |
|
|
0 commit comments