@@ -184,42 +184,55 @@ def _session_tests(
184
184
) -> None :
185
185
# check for presence of tests
186
186
test_list = glob .glob ("*_test.py" ) + glob .glob ("test_*.py" )
187
+ test_list .extend (glob .glob ("tests" ))
188
+
187
189
if len (test_list ) == 0 :
188
190
print ("No tests found, skipping directory." )
189
- else :
190
- if TEST_CONFIG ["pip_version_override" ]:
191
- pip_version = TEST_CONFIG ["pip_version_override" ]
192
- session .install (f"pip=={ pip_version } " )
193
- """Runs py.test for a particular project."""
194
- if os .path .exists ("requirements.txt" ):
195
- if os .path .exists ("constraints.txt" ):
196
- session .install ("-r" , "requirements.txt" , "-c" , "constraints.txt" )
197
- else :
198
- session .install ("-r" , "requirements.txt" )
199
-
200
- if os .path .exists ("requirements-test.txt" ):
201
- if os .path .exists ("constraints-test.txt" ):
202
- session .install (
203
- "-r" , "requirements-test.txt" , "-c" , "constraints-test.txt"
204
- )
205
- else :
206
- session .install ("-r" , "requirements-test.txt" )
207
-
208
- if INSTALL_LIBRARY_FROM_SOURCE :
209
- session .install ("-e" , _get_repo_root ())
210
-
211
- if post_install :
212
- post_install (session )
213
-
214
- session .run (
215
- "pytest" ,
216
- * (PYTEST_COMMON_ARGS + session .posargs ),
217
- # Pytest will return 5 when no tests are collected. This can happen
218
- # on travis where slow and flaky tests are excluded.
219
- # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
220
- success_codes = [0 , 5 ],
221
- env = get_pytest_env_vars (),
222
- )
191
+ return
192
+
193
+ if TEST_CONFIG ["pip_version_override" ]:
194
+ pip_version = TEST_CONFIG ["pip_version_override" ]
195
+ session .install (f"pip=={ pip_version } " )
196
+ """Runs py.test for a particular project."""
197
+ concurrent_args = []
198
+ if os .path .exists ("requirements.txt" ):
199
+ if os .path .exists ("constraints.txt" ):
200
+ session .install ("-r" , "requirements.txt" , "-c" , "constraints.txt" )
201
+ else :
202
+ session .install ("-r" , "requirements.txt" )
203
+ with open ("requirements.txt" ) as rfile :
204
+ packages = rfile .read ()
205
+
206
+ if os .path .exists ("requirements-test.txt" ):
207
+ if os .path .exists ("constraints-test.txt" ):
208
+ session .install (
209
+ "-r" , "requirements-test.txt" , "-c" , "constraints-test.txt"
210
+ )
211
+ else :
212
+ session .install ("-r" , "requirements-test.txt" )
213
+ with open ("requirements-test.txt" ) as rtfile :
214
+ packages += rtfile .read ()
215
+
216
+ if INSTALL_LIBRARY_FROM_SOURCE :
217
+ session .install ("-e" , _get_repo_root ())
218
+
219
+ if post_install :
220
+ post_install (session )
221
+
222
+ if "pytest-parallel" in packages :
223
+ concurrent_args .extend (['--workers' , 'auto' , '--tests-per-worker' , 'auto' ])
224
+ elif "pytest-xdist" in packages :
225
+ concurrent_args .extend (['-n' , 'auto' ])
226
+
227
+ session .run (
228
+ "pytest" ,
229
+ * (PYTEST_COMMON_ARGS + session .posargs + concurrent_args ),
230
+ # Pytest will return 5 when no tests are collected. This can happen
231
+ # on travis where slow and flaky tests are excluded.
232
+ # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
233
+ success_codes = [0 , 5 ],
234
+ env = get_pytest_env_vars (),
235
+ )
223
236
224
237
225
238
@nox .session (python = ALL_VERSIONS )
0 commit comments