Skip to content

Commit 59ab8d2

Browse files
smarieSylvain MARIE
andauthored
Feature/323 import file mismatch (#324)
* Latest version of `nox_utils` * Fixed import errors with latest pytest * changelog and noxfile for pytest 8 * Fixes part of #321 by solving issues related to the new fixture event_loop_policy in our tests * Fixed tests. updated changelog * Fixed pytest-asyncio 0.23 issue --------- Co-authored-by: Sylvain MARIE <[email protected]>
1 parent 998429f commit 59ab8d2

File tree

15 files changed

+85
-13
lines changed

15 files changed

+85
-13
lines changed

ci_tools/nox_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import os
44
import re
5+
from shlex import split
56
import shutil
67
import subprocess
78
import sys
@@ -130,7 +131,7 @@ def run2(self, command: Union[Iterable[str], str], logfile: Union[bool, str, Pat
130131
:return:
131132
"""
132133
if isinstance(command, str):
133-
command = command.split(" ")
134+
command = split(command)
134135

135136
self.run(*command, logfile=logfile, **kwargs)
136137

@@ -632,7 +633,8 @@ def _f_wrapper(**kwargs):
632633
except KeyError:
633634
# Skip this session, it is a dummy one
634635
nox_logger.warning(
635-
"Skipping configuration, this is not supported in python version %r" % session.python
636+
"Skipping configuration, %r is not meant to be executed in this now session for python version %r" %
637+
(grid_param if has_parameter else "this", session.python)
636638
)
637639
return
638640

docs/changelog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
### 3.8.2 (in progress) - bugfixes
3+
### 3.8.2 - bugfixes and project improvements
44

55
- Corrected API documentation (and comments) for the second file-name
66
pattern for `AUTO`-cases lookup (`cases_<name>.py` instead of
@@ -10,6 +10,13 @@
1010
Fixes [#309](https://github.com/smarie/python-pytest-cases/issues/309). PR
1111
[#320](https://github.com/smarie/python-pytest-cases/pull/320) by
1212
[@michele-riva](https://github.com/michele-riva).
13+
- Improved error message in case of cases loading error in `@parametrize_with_cases` when the `cases` argument
14+
is a string refering to a relative or absolute module name. Fixed `import file mismatch` with
15+
pytest 8 when executing our own tests.
16+
Fixes [#323](https://github.com/smarie/python-pytest-cases/issues/323).
17+
- Fixed failing tests in our builds due to the `event_loop_policy` fixture that appeared in `pytest-asyncio` `0.23`.
18+
Fixes part of
19+
[#321](https://github.com/smarie/python-pytest-cases/issues/321).
1320

1421
### 3.8.1 - bugfixes
1522

noxfile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@
1919

2020

2121
ENVS = {
22+
# python 3.12
2223
(PY312, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}},
24+
(PY312, "pytest7.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<8"}},
25+
# python 3.11
2326
(PY311, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}},
27+
# python 3.10
2428
(PY310, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}},
2529
# python 3.9 - put first to detect easy issues faster.
2630
(PY39, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}},
31+
(PY39, "pytest7.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<8"}},
2732
(PY39, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}},
2833
# python 3.8
2934
(PY38, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<5"}},
3035
(PY38, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6", "pytest-asyncio": DONT_INSTALL}},
3136
(PY38, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}},
37+
(PY38, "pytest7.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<8"}},
3238
(PY38, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}},
3339
# python 2.7
3440
(PY27, "pytest3.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<4", "pytest-asyncio": DONT_INSTALL}},
@@ -48,6 +54,7 @@
4854
(PY37, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<5"}},
4955
(PY37, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6", "pytest-asyncio": DONT_INSTALL}},
5056
(PY37, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}},
57+
(PY37, "pytest7.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<8"}},
5158
# IMPORTANT: this should be last so that the folder docs/reports is not deleted afterwards
5259
(PY37, "pytest-latest"): {"coverage": True, "pkg_specs": {"pip": ">19", "pytest": ""}}
5360
}

src/pytest_cases/case_parametrizer_new.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,13 @@ def extract_cases_from_module(module, # type: ModuleRe
789789
"""
790790
# optionally import module if passed as module name string
791791
if isinstance(module, string_types):
792-
module = import_module(module, package=package_name)
792+
try:
793+
module = import_module(module, package=package_name)
794+
except ModuleNotFoundError as e:
795+
raise ModuleNotFoundError(
796+
"Error loading cases from module. `import_module(%r, package=%r)` raised an error: %r"
797+
% (module, package_name, e)
798+
)
793799

794800
return _extract_cases_from_module_or_class(module=module, _case_param_factory=_case_param_factory,
795801
case_fun_prefix=case_fun_prefix)

src/pytest_cases/pep492.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async def wrapped_fixture_func(*_args, **_kwargs):
3131

3232
return wrapped_fixture_func
3333

34+
3435
def _parametrize_plus_decorate_coroutine_pep492(
3536
test_func,
3637
new_sig,

tests/cases/issues/issue_196/__init__.py

Whitespace-only changes.

tests/cases/issues/issue_309/__init__.py

Whitespace-only changes.

tests/cases/issues/issue_311/__init__.py

Whitespace-only changes.

tests/cases/issues/issue_311/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33

44
@fixture(scope='session')
5-
@parametrize_with_cases('arg', cases='cases', scope='session')
5+
@parametrize_with_cases('arg', cases='.cases', scope='session')
66
def scope_mismatch(arg):
77
return [arg]
88

9+
910
session_scoped = scope_mismatch

tests/cases/issues/issue_311/test_issue_311/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)