|
13 | 13 | # limitations under the License. |
14 | 14 | """Dev commands.""" |
15 | 15 | import pathlib |
| 16 | +import tempfile |
16 | 17 |
|
17 | 18 | import nox |
18 | 19 |
|
@@ -51,38 +52,45 @@ def type_check(session): |
51 | 52 | @nox.session(python=["3.7", "3.8", "3.9", "3.10"]) |
52 | 53 | def tests(session): |
53 | 54 | """Execute tests.""" |
54 | | - session.install("poetry") |
55 | | - session.run("poetry", "install") |
56 | | - tests_path = pathlib.Path("tests") |
57 | | - if "unit" in session.posargs: |
58 | | - tests_path = tests_path / "unit" |
59 | | - if "integration" in session.posargs: |
60 | | - tests_path = tests_path / "integration" |
61 | | - if "pytest_verbose" in session.posargs: |
62 | | - session.run( |
63 | | - "poetry", |
64 | | - "run", |
65 | | - "coverage", |
66 | | - "run", |
67 | | - "--source=bqms_run", |
68 | | - "-m", |
69 | | - "pytest", |
70 | | - "-vv", |
71 | | - "--log-cli-level=INFO", |
72 | | - "--log-cli-format=" |
73 | | - "%(asctime)s: %(levelname)s: %(threadName)s: " |
74 | | - "%(filename)s:%(lineno)s: %(message)s", |
75 | | - tests_path.as_posix(), |
76 | | - ) |
77 | | - else: |
| 55 | + with tempfile.NamedTemporaryFile() as temp_file: |
| 56 | + session.install("poetry") |
78 | 57 | session.run( |
79 | 58 | "poetry", |
80 | | - "run", |
81 | | - "coverage", |
82 | | - "run", |
83 | | - "--source=bqms_run", |
84 | | - "-m", |
85 | | - "pytest", |
86 | | - tests_path.as_posix(), |
| 59 | + "export", |
| 60 | + "--with", |
| 61 | + "dev", |
| 62 | + "--without-hashes", |
| 63 | + "--output", |
| 64 | + temp_file.name, |
87 | 65 | ) |
88 | | - session.run("poetry", "run", "coverage", "report", "-m") |
| 66 | + session.install("-r", temp_file.name) |
| 67 | + session.install(".") |
| 68 | + tests_path = pathlib.Path("tests") |
| 69 | + if "unit" in session.posargs: |
| 70 | + tests_path = tests_path / "unit" |
| 71 | + if "integration" in session.posargs: |
| 72 | + tests_path = tests_path / "integration" |
| 73 | + if "pytest_verbose" in session.posargs: |
| 74 | + session.run( |
| 75 | + "coverage", |
| 76 | + "run", |
| 77 | + "--source=bqms_run", |
| 78 | + "-m", |
| 79 | + "pytest", |
| 80 | + "-vv", |
| 81 | + "--log-cli-level=INFO", |
| 82 | + "--log-cli-format=" |
| 83 | + "%(asctime)s: %(levelname)s: %(threadName)s: " |
| 84 | + "%(filename)s:%(lineno)s: %(message)s", |
| 85 | + tests_path.as_posix(), |
| 86 | + ) |
| 87 | + else: |
| 88 | + session.run( |
| 89 | + "coverage", |
| 90 | + "run", |
| 91 | + "--source=bqms_run", |
| 92 | + "-m", |
| 93 | + "pytest", |
| 94 | + tests_path.as_posix(), |
| 95 | + ) |
| 96 | + session.run("coverage", "report", "-m") |
0 commit comments