diff --git a/noxfile.py b/noxfile.py index 07c75a84..73df7c28 100644 --- a/noxfile.py +++ b/noxfile.py @@ -22,9 +22,11 @@ # (PY310, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, # python 3.9 - put first to detect easy issues faster. (PY39, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, + (PY39, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}}, # python 3.8 (PY38, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<5"}}, - (PY38, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6"}}, + (PY38, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6", "pytest-asyncio": DONT_INSTALL}}, + (PY38, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}}, (PY38, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, # python 2.7 (PY27, "pytest2.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<3", "pytest-asyncio": DONT_INSTALL}}, @@ -35,16 +37,17 @@ (PY35, "pytest3.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<4", "pytest-asyncio": DONT_INSTALL}}, (PY35, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<5", "pytest-asyncio": DONT_INSTALL}}, (PY35, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<6"}}, - (PY35, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": ""}}, # python 3.6 (PY36, "pytest3.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<4"}}, (PY36, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<5"}}, (PY36, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6"}}, + (PY36, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}}, (PY36, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, # python 3.7 (PY37, "pytest3.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<4"}}, (PY37, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<5"}}, - (PY37, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6"}}, + (PY37, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6", "pytest-asyncio": DONT_INSTALL}}, + (PY37, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}}, # IMPORTANT: this should be last so that the folder docs/reports is not deleted afterwards (PY37, "pytest-latest"): {"coverage": True, "pkg_specs": {"pip": ">19", "pytest": ""}} } @@ -123,17 +126,20 @@ def tests(session: PowerSession, coverage, pkg_specs): # Fail if the assumed python version is not the actual one session.run2("python ci_tools/check_python_version.py %s" % session.python) - # install self so that it is recognized by pytest - session.run2("pip install -e . --no-deps") - # check that it can be imported even from a different folder - session.run2(['python', '-c', '"import os; os.chdir(\'./docs/\'); import %s"' % pkg_name]) + # session.run2(['python', '-c', '"import os; os.chdir(\'./docs/\'); import %s"' % pkg_name]) # finally run all tests if not coverage: + # install self + session.run2("pip install . --no-deps") + # simple: pytest only session.run2("python -m pytest --cache-clear -v tests/") else: + # install self in dev mode so that coverage works + session.run2("pip install -e . --no-deps") + # coverage + junit html reports + badge generation session.install_reqs(phase="coverage", phase_reqs=["coverage", "pytest-html", "genbadge[tests,coverage]"], @@ -162,7 +168,7 @@ def flake8(session: PowerSession): session.install("-r", str(Folders.ci_tools / "flake8-requirements.txt")) session.install("genbadge[flake8]") - session.run2("pip install -e .[flake8]") + session.run2("pip install .") rm_folder(Folders.flake8_reports) Folders.flake8_reports.mkdir(parents=True, exist_ok=True) diff --git a/src/pytest_cases/common_others.py b/src/pytest_cases/common_others.py index 1f3bd255..38d3e7ba 100644 --- a/src/pytest_cases/common_others.py +++ b/src/pytest_cases/common_others.py @@ -15,7 +15,7 @@ except ImportError: pass -from .common_mini_six import string_types, PY3 +from .common_mini_six import string_types, PY3, PY34 def get_code_first_line(f): @@ -573,3 +573,15 @@ def make_identifier(name # type: str if re.match("^(?=\\d)", new_name): new_name = "_" + new_name return new_name + + +if PY34: + def replace_list_contents(the_list, new_contents): + """Replaces the contents of a list""" + the_list.clear() + the_list.extend(new_contents) +else: + def replace_list_contents(the_list, new_contents): + """Replaces the contents of a list""" + del the_list[:] + the_list.extend(new_contents) diff --git a/src/pytest_cases/fixture_parametrize_plus.py b/src/pytest_cases/fixture_parametrize_plus.py index 43b0f0c7..800dd1e0 100644 --- a/src/pytest_cases/fixture_parametrize_plus.py +++ b/src/pytest_cases/fixture_parametrize_plus.py @@ -26,7 +26,7 @@ from makefun import with_signature, remove_signature_parameters, add_signature_parameters, wraps from .common_mini_six import string_types -from .common_others import AUTO, robust_isinstance +from .common_others import AUTO, robust_isinstance, replace_list_contents from .common_pytest_marks import has_pytest_param, get_param_argnames_as_list from .common_pytest_lazy_values import is_lazy_value, get_lazy_args from .common_pytest import get_fixture_name, remove_duplicates, mini_idvalset, is_marked_parameter_value, \ @@ -553,11 +553,11 @@ def get_alternative_id(self): if has_pytest_param: def remove_empty_ids(callspec): # used by plugin.py to remove the EMPTY_ID from the callspecs - callspec._idlist = [c for c in callspec._idlist if not c.startswith(EMPTY_ID)] + replace_list_contents(callspec._idlist, [c for c in callspec._idlist if not c.startswith(EMPTY_ID)]) else: def remove_empty_ids(callspec): # used by plugin.py to remove the EMPTY_ID from the callspecs - callspec._idlist = [c for c in callspec._idlist if not c.endswith(EMPTY_ID)] + replace_list_contents(callspec._idlist, [c for c in callspec._idlist if not c.endswith(EMPTY_ID)]) # elif PYTEST421_OR_GREATER: diff --git a/tests/pytest_extension/fixtures/fixture_plus_and_others/test_fixtures_parametrize.py b/tests/pytest_extension/fixtures/fixture_plus_and_others/test_fixtures_parametrize.py index aa65751f..d52484e2 100644 --- a/tests/pytest_extension/fixtures/fixture_plus_and_others/test_fixtures_parametrize.py +++ b/tests/pytest_extension/fixtures/fixture_plus_and_others/test_fixtures_parametrize.py @@ -77,14 +77,15 @@ def test_three(myfix2, myfix3): print(myfix2) - def test_synthesis(module_results_dct): + def test_synthesis2(module_results_dct): """Use pytest-harvest to check that the list of executed tests is correct """ assert list(module_results_dct) == ['test_one[one-one]', 'test_one[one-two]', 'test_one[two-one]', 'test_one[two-two]', + 'test_synthesis', 'test_two[1-2-!0!]', 'test_two[p_a-!0!]', 'test_three[1-2-!0!-a]', - 'test_three[p_a-!0!-a]'] \ No newline at end of file + 'test_three[p_a-!0!-a]']