@@ -184,37 +184,44 @@ PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
184
184
def _session_tests(
185
185
session: nox.sessions.Session, post_install: Callable = None
186
186
) -> None:
187
- if TEST_CONFIG["pip_version_override"]:
188
- pip_version = TEST_CONFIG["pip_version_override"]
189
- session.install(f"pip=={pip_version}")
190
- """Runs py.test for a particular project."""
191
- if os.path.exists("requirements.txt"):
192
- if os.path.exists("constraints.txt"):
193
- session.install("-r", "requirements.txt", "-c", "constraints.txt")
194
- else:
195
- session.install("-r", "requirements.txt")
196
-
197
- if os.path.exists("requirements-test.txt"):
198
- if os.path.exists("constraints-test.txt"):
199
- session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
200
- else:
201
- session.install("-r", "requirements-test.txt")
202
-
203
- if INSTALL_LIBRARY_FROM_SOURCE:
204
- session.install("-e", _get_repo_root())
205
-
206
- if post_install:
207
- post_install(session)
208
-
209
- session.run(
210
- "pytest",
211
- *(PYTEST_COMMON_ARGS + session.posargs),
212
- # Pytest will return 5 when no tests are collected. This can happen
213
- # on travis where slow and flaky tests are excluded.
214
- # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
215
- success_codes=[0, 5],
216
- env=get_pytest_env_vars(),
217
- )
187
+ # check for presence of tests
188
+ test_list = glob.glob("*_test.py") + glob.glob("test_*.py")
189
+ if len(test_list) == 0:
190
+ print("No tests found, skipping directory.")
191
+ else:
192
+ if TEST_CONFIG["pip_version_override"]:
193
+ pip_version = TEST_CONFIG["pip_version_override"]
194
+ session.install(f"pip=={pip_version}")
195
+ """Runs py.test for a particular project."""
196
+ if os.path.exists("requirements.txt"):
197
+ if os.path.exists("constraints.txt"):
198
+ session.install("-r", "requirements.txt", "-c", "constraints.txt")
199
+ else:
200
+ session.install("-r", "requirements.txt")
201
+
202
+ if os.path.exists("requirements-test.txt"):
203
+ if os.path.exists("constraints-test.txt"):
204
+ session.install(
205
+ "-r", "requirements-test.txt", "-c", "constraints-test.txt"
206
+ )
207
+ else:
208
+ session.install("-r", "requirements-test.txt")
209
+
210
+ if INSTALL_LIBRARY_FROM_SOURCE:
211
+ session.install("-e", _get_repo_root())
212
+
213
+ if post_install:
214
+ post_install(session)
215
+
216
+ session.run(
217
+ "pytest",
218
+ *(PYTEST_COMMON_ARGS + session.posargs),
219
+ # Pytest will return 5 when no tests are collected. This can happen
220
+ # on travis where slow and flaky tests are excluded.
221
+ # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
222
+ success_codes=[0, 5],
223
+ env=get_pytest_env_vars(),
224
+ )
218
225
219
226
220
227
@nox.session(python=ALL_VERSIONS)
0 commit comments