From 5c94270f752e0b07b02da901be58f20a90ce0585 Mon Sep 17 00:00:00 2001 From: inmantaci Date: Fri, 13 May 2022 17:48:49 +0200 Subject: [PATCH 01/32] Bump version: 2.4.0 --- .bumpversion.cfg | 2 +- CHANGELOG.md | 3 +++ setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index f9890a3..2daa7b7 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.3.0 +current_version = 2.4.0 tag = False commit = False diff --git a/CHANGELOG.md b/CHANGELOG.md index eef8896..d9c529c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# v 2.4.0 (?) +Changes in this release: + # v 2.3.0 (2022-05-13) Changes in this release: - Added test parameter framework (#288). diff --git a/setup.py b/setup.py index b6f3848..18c74b7 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="pytest-inmanta", - version="2.3.0", + version="2.4.0", description=( "A py.test plugin providing fixtures to simplify inmanta modules testing." ), From 23e378dcfb9ac719f92aa228f03c30c383060011 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 May 2022 11:49:22 +0200 Subject: [PATCH 02/32] Bump inmanta-dev-dependencies from 2.17.0 to 2.18.0 (#290) Bumps [inmanta-dev-dependencies]() from 2.17.0 to 2.18.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 66bb7af..df2372a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.17.0; python_version > '3.6' +inmanta-dev-dependencies==2.18.0; python_version > '3.6' inmanta-core pydantic==1.9.0 pyyaml==6.0 From 09a32ff0b565b4833f04de76f20b37d2a576898b Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 16 May 2022 14:07:32 +0200 Subject: [PATCH 03/32] Issue/set pytest option default to none (#291) * Add default value to addoption * Added changelog entry Co-authored-by: Guillaume Everarts de Velp --- CHANGELOG.md | 4 ++++ pytest_inmanta/plugin.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c529c..9809ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # v 2.4.0 (?) Changes in this release: +# v 2.3.1 (2022-05-16) +Changes in this release: + - Fixed test parameter framework for boolean options. + # v 2.3.0 (2022-05-13) Changes in this release: - Added test parameter framework (#288). diff --git a/pytest_inmanta/plugin.py b/pytest_inmanta/plugin.py index 6671b42..6789905 100644 --- a/pytest_inmanta/plugin.py +++ b/pytest_inmanta/plugin.py @@ -93,6 +93,11 @@ def pytest_addoption(parser: "Parser") -> None: kwargs: Dict[str, object] = dict( action=param.action, help=param.help, + # We overwrite the default here, to ensure that even boolean options don't default to the opposite of + # the store action. If we don't do this, config.getoption will always return a value, either True or + # False depending on the action and whether the flag is set or not, this makes it impossible to use + # environment variables for the option. + default=None, ) if param.choices is not None: kwargs["choices"] = param.choices From 85e0ecbcb0edee3a69690560176e4a709b47f563 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 17 May 2022 14:47:57 +0200 Subject: [PATCH 04/32] Issue/support late parameter registration (#292) * Update test_parameter framework * Add changelog entry Co-authored-by: Guillaume Everarts de Velp --- CHANGELOG.md | 4 ++ pytest_inmanta/parameters.py | 6 +- pytest_inmanta/plugin.py | 26 +------- pytest_inmanta/test_parameter/parameter.py | 75 +++++++++++++++++++++- 4 files changed, 82 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9809ff0..b69b537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # v 2.4.0 (?) Changes in this release: +# v 2.3.2 (2022-05-17) +Changes in this release: + - Allow other plugins to register test parameters after pytest has loaded pytest-inmanta plugin. + # v 2.3.1 (2022-05-16) Changes in this release: - Fixed test parameter framework for boolean options. diff --git a/pytest_inmanta/parameters.py b/pytest_inmanta/parameters.py index b2ab2f3..f6a25ab 100644 --- a/pytest_inmanta/parameters.py +++ b/pytest_inmanta/parameters.py @@ -73,14 +73,13 @@ "Location to download modules from." "Can be specified multiple times to add multiple locations" ), - default=["https://github.com/inmanta/"], ) inm_mod_repo = ListTestParameter( argument="--module-repo", environment_variable=inm_mod_repo_legacy.environment_variable, usage=inm_mod_repo_legacy.usage, - default=inm_mod_repo_legacy.default, + default=["https://github.com/inmanta/"], group=param_group, legacy=inm_mod_repo_legacy, ) @@ -93,7 +92,6 @@ environment_variable="INMANTA_INSTALL_MODE", usage="Install mode for modules downloaded during this test", enum=InstallMode, - default=InstallMode.release, ) inm_install_mode = EnumTestParameter( @@ -101,7 +99,7 @@ environment_variable=inm_install_mode_legacy.environment_variable, usage=inm_install_mode_legacy.usage, enum=inm_install_mode_legacy.enum, - default=inm_install_mode_legacy.default, + default=InstallMode.release, group=param_group, legacy=inm_install_mode_legacy, ) diff --git a/pytest_inmanta/plugin.py b/pytest_inmanta/plugin.py index 6789905..7f12c24 100644 --- a/pytest_inmanta/plugin.py +++ b/pytest_inmanta/plugin.py @@ -34,7 +34,7 @@ from pathlib import Path from textwrap import dedent from types import FunctionType, ModuleType -from typing import Dict, Iterator, List, Optional, Set, Tuple, Union +from typing import Dict, Iterator, List, Optional, Set, Tuple import pydantic import pytest @@ -72,7 +72,7 @@ Those classes are only used in type annotation, but the import doesn't work in python 3.6. So we simply catch the error and ignore it. """ - from pytest import CaptureFixture, OptionGroup, Parser + from pytest import CaptureFixture, Parser except ImportError: pass @@ -82,27 +82,7 @@ def pytest_addoption(parser: "Parser") -> None: - for group_name, parameters in TestParameterRegistry.test_parameter_groups().items(): - group: Union["Parser", "OptionGroup"] - if group_name is None: - group = parser - else: - group = parser.getgroup(group_name) - - for param in parameters: - kwargs: Dict[str, object] = dict( - action=param.action, - help=param.help, - # We overwrite the default here, to ensure that even boolean options don't default to the opposite of - # the store action. If we don't do this, config.getoption will always return a value, either True or - # False depending on the action and whether the flag is set or not, this makes it impossible to use - # environment variables for the option. - default=None, - ) - if param.choices is not None: - kwargs["choices"] = param.choices - - group.addoption(param.argument, **kwargs) + TestParameterRegistry.pytest_addoption(parser) def get_module() -> typing.Tuple[module.Module, str]: diff --git a/pytest_inmanta/test_parameter/parameter.py b/pytest_inmanta/test_parameter/parameter.py index 192f8a5..c12a5bc 100644 --- a/pytest_inmanta/test_parameter/parameter.py +++ b/pytest_inmanta/test_parameter/parameter.py @@ -20,14 +20,14 @@ import uuid from abc import abstractmethod from collections import defaultdict -from typing import Container, Dict, Generic, List, Optional, Set, TypeVar +from typing import Container, Dict, Generic, List, Optional, Set, TypeVar, Union try: """ Those classes are only used in type annotation, but the import doesn't work in python 3.6. So we simply catch the error and ignore it. """ - from pytest import Config + from pytest import Config, OptionGroup, Parser except ImportError: pass @@ -65,6 +65,39 @@ class TestParameterRegistry: __test_parameter_groups: Dict[Optional[str], Set["TestParameter"]] = defaultdict( set ) + __parser: Optional["Parser"] = None + + @staticmethod + def add_option( + parser: "Parser", group_name: Optional[str], test_parameter: "TestParameter" + ) -> None: + """ + This static method adds the option defined in test_parameter to the parser provided in argument. + If group_name is not None, the option will be added to the group named :param group_name:. + + :param parser: The parser to register the option in + :param group_name: The name of the group the option is a part of + :param test_parameter: The test parameter holding all the option's information + """ + group: Union["Parser", "OptionGroup"] + if group_name is None: + group = parser + else: + group = parser.getgroup(group_name) + + kwargs: Dict[str, object] = dict( + action=test_parameter.action, + help=test_parameter.help, + # We overwrite the default here, to ensure that even boolean options don't default to the opposite of + # the store action. If we don't do this, config.getoption will always return a value, either True or + # False depending on the action and whether the flag is set or not, this makes it impossible to use + # environment variables for the option. + default=None, + ) + if test_parameter.choices is not None: + kwargs["choices"] = test_parameter.choices + + group.addoption(test_parameter.argument, **kwargs) @classmethod def register( @@ -73,17 +106,34 @@ def register( test_parameter: "TestParameter", group: Optional[str] = None, ) -> None: + """ + Register a parameter, you should not call this method your self. + This method is called by the constructor of TestParameter. + """ if key is None: key = str(uuid.uuid4()) + cls.__test_parameters[key] = test_parameter cls.__test_parameter_groups[group].add(test_parameter) + if cls.__parser is not None: + # Pytest has already loaded this plugin, we need to add the option now + TestParameterRegistry.add_option(cls.__parser, group, test_parameter) + @classmethod def test_parameters(cls) -> List["TestParameter"]: + """ + Get all the registered parameters + """ return sorted(cls.__test_parameters.values(), key=lambda param: param.argument) @classmethod def test_parameter_groups(cls) -> Dict[Optional[str], List["TestParameter"]]: + """ + Get all the registered parameters, grouped by group name. The output is a dict holding + for each group name (key) the list of all parameters (value). The parameters which are + not part of a group are grouped in a list at key None. + """ return { group: sorted(parameters, key=lambda param: param.argument) for group, parameters in cls.__test_parameter_groups.items() @@ -91,8 +141,29 @@ def test_parameter_groups(cls) -> Dict[Optional[str], List["TestParameter"]]: @classmethod def test_parameter(cls, key: str) -> "TestParameter": + """ + Get the parameter that was created with key :param key:, if it is not found, raise a KeyError + """ return cls.__test_parameters[key] + @classmethod + def pytest_addoption(cls, parser: "Parser") -> None: + """ + This method should be called once (and only once) in pytest_inmanta.plugin.pytest_addoption + It will register the parser for later use and setup all the options that have already been + registered. + """ + if cls.__parser == parser: + raise RuntimeError("Options can not be registered more than once") + + # Saving the parser for late option registration + cls.__parser = parser + + # We setup all the options that are already registered + for group_name, parameters in cls.test_parameter_groups().items(): + for param in parameters: + TestParameterRegistry.add_option(parser, group_name, param) + class TestParameter(Generic[ParameterType]): """ From dd4d78ae85cfe3edfe6a0f8e2dad81714d6ffb3b Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 18 May 2022 09:48:16 +0200 Subject: [PATCH 05/32] Issue/fix incomplete parameter registration (#293) * Fix incomplete parameter registration * Add changelog entry Co-authored-by: Guillaume Everarts de Velp --- CHANGELOG.md | 4 ++++ pytest_inmanta/test_parameter/enum_parameter.py | 2 +- pytest_inmanta/test_parameter/path_parameter.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b69b537..abf1382 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # v 2.4.0 (?) Changes in this release: +# v 2.3.3 (2022-05-18) +Changes in this release: + - Fix enum test parameters registered after pytest has loaded pytest-inmanta plugin. + # v 2.3.2 (2022-05-17) Changes in this release: - Allow other plugins to register test parameters after pytest has loaded pytest-inmanta plugin. diff --git a/pytest_inmanta/test_parameter/enum_parameter.py b/pytest_inmanta/test_parameter/enum_parameter.py index 5856539..d705107 100644 --- a/pytest_inmanta/test_parameter/enum_parameter.py +++ b/pytest_inmanta/test_parameter/enum_parameter.py @@ -53,6 +53,7 @@ def __init__( group: Optional[str] = None, legacy: Optional["EnumTestParameter[E]"] = None, ) -> None: + self.enum = enum super().__init__( argument, environment_variable, @@ -62,7 +63,6 @@ def __init__( group=group, legacy=legacy, ) - self.enum = enum @property def choices(self) -> Optional[Container[str]]: diff --git a/pytest_inmanta/test_parameter/path_parameter.py b/pytest_inmanta/test_parameter/path_parameter.py index dafc7c1..51fe4ed 100644 --- a/pytest_inmanta/test_parameter/path_parameter.py +++ b/pytest_inmanta/test_parameter/path_parameter.py @@ -57,6 +57,8 @@ def __init__( is_file: Optional[bool] = None, exists: Optional[bool] = None, ) -> None: + self.is_file = is_file + self.exists = exists if is_file is None else True super().__init__( argument, environment_variable, @@ -66,8 +68,6 @@ def __init__( group=group, legacy=legacy, ) - self.is_file = is_file - self.exists = exists if is_file is None else True def validate(self, raw_value: object) -> Path: path = Path(str(raw_value)).absolute() From f04827028197ce5e473c8971fd29fe34fbb7a927 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 May 2022 11:49:25 +0200 Subject: [PATCH 06/32] Bump pydantic from 1.9.0 to 1.9.1 (#294) Bumps [pydantic](https://github.com/samuelcolvin/pydantic) from 1.9.0 to 1.9.1. - [Release notes](https://github.com/samuelcolvin/pydantic/releases) - [Changelog](https://github.com/samuelcolvin/pydantic/blob/v1.9.1/HISTORY.md) - [Commits](https://github.com/samuelcolvin/pydantic/compare/v1.9.0...v1.9.1) --- updated-dependencies: - dependency-name: pydantic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index df2372a..7309864 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' inmanta-dev-dependencies==2.18.0; python_version > '3.6' inmanta-core -pydantic==1.9.0 +pydantic==1.9.1 pyyaml==6.0 From 5f223a956ad7767034d785d93e0248c1d4c37794 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 May 2022 11:49:21 +0200 Subject: [PATCH 07/32] Bump inmanta-dev-dependencies from 2.18.0 to 2.19.0 (#295) Bumps [inmanta-dev-dependencies]() from 2.18.0 to 2.19.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7309864..7bf35e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.18.0; python_version > '3.6' +inmanta-dev-dependencies==2.19.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 73028d0def091359626dfa8759880a3e34f35c02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 11:49:21 +0200 Subject: [PATCH 08/32] Bump inmanta-dev-dependencies from 2.19.0 to 2.20.0 (#296) Bumps [inmanta-dev-dependencies]() from 2.19.0 to 2.20.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7bf35e1..f53afe5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.19.0; python_version > '3.6' +inmanta-dev-dependencies==2.20.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 384cb3be2f9e737c3f2de9291b84a92caf0a1689 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jun 2022 11:49:24 +0200 Subject: [PATCH 09/32] Bump inmanta-dev-dependencies from 2.20.0 to 2.21.0 (#298) Bumps [inmanta-dev-dependencies]() from 2.20.0 to 2.21.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f53afe5..1b8d334 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.20.0; python_version > '3.6' +inmanta-dev-dependencies==2.21.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 6efe9dfea73bd4a7b7d2f43e0f455f96d1aee072 Mon Sep 17 00:00:00 2001 From: Hugo-Inmanta <98876549+Hugo-Inmanta@users.noreply.github.com> Date: Wed, 8 Jun 2022 13:41:17 +0200 Subject: [PATCH 10/32] Issue/189 add support for changing state dir to a writable location by the current user (#297) * [DOC] add changelog * [FEAT] add fixture to change Inmanta state dir to a writable location for the current user * [FIX] return type * [FEAT] define state dir in conftest * [FIX] move logic around * [FORMAT] comply to pep8 * [FIX] add requested changes * [TYPING] add type hints --- CHANGELOG.md | 1 + pytest_inmanta/plugin.py | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abf1382..895da2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # v 2.4.0 (?) Changes in this release: +- Add fixture to change the Inmanta state dir to a writable location for the current user. # v 2.3.3 (2022-05-18) Changes in this release: diff --git a/pytest_inmanta/plugin.py b/pytest_inmanta/plugin.py index 7f12c24..b45aede 100644 --- a/pytest_inmanta/plugin.py +++ b/pytest_inmanta/plugin.py @@ -43,7 +43,9 @@ import inmanta.ast from inmanta import compiler, config, const, module, plugins, protocol -from inmanta.agent import cache, handler +from inmanta.agent import cache +from inmanta.agent import config as inmanta_config +from inmanta.agent import handler from inmanta.agent import io as agent_io from inmanta.agent.handler import HandlerContext, ResourceHandler from inmanta.const import ResourceState @@ -55,8 +57,16 @@ from inmanta.resources import Resource if typing.TYPE_CHECKING: + # Local type stub for mypy that works with both pytest < 7 and pytest >=7 + # https://docs.pytest.org/en/7.1.x/_modules/_pytest/legacypath.html#TempdirFactory + import py from inmanta.agent.io.local import IOBase + class TempdirFactory: + def mktemp(self, path: str) -> py.path.local: + ... + + from .handler import DATA from .parameters import ( inm_install_mode, @@ -125,7 +135,7 @@ def inmanta_plugins( @pytest.fixture() def project( - project_shared: "Project", capsys: "CaptureFixture" + project_shared: "Project", capsys: "CaptureFixture", set_inmanta_state_dir: None ) -> typing.Iterator["Project"]: DATA.clear() project_shared.clean() @@ -136,7 +146,9 @@ def project( @pytest.fixture() def project_no_plugins( - project_shared_no_plugins: "Project", capsys: "CaptureFixture" + project_shared_no_plugins: "Project", + capsys: "CaptureFixture", + set_inmanta_state_dir: None, ) -> typing.Iterator["Project"]: warnings.warn( DeprecationWarning( @@ -1130,3 +1142,19 @@ def finalize_handler(self, handler: ResourceHandler) -> None: def finalize_all_handlers(self) -> None: for handler_instance in self._handlers: self.finalize_handler(handler_instance) + + +@pytest.fixture(scope="function") +def inmanta_state_dir(tmpdir_factory: "TempdirFactory") -> Iterator[str]: + """ + This fixture can be overridden in the conftest of any individual project + in order to set the Inmanta state directory at the desired level. + """ + inmanta_state_dir = tmpdir_factory.mktemp("inmanta_state_dir") + yield str(inmanta_state_dir) + inmanta_state_dir.remove() + + +@pytest.fixture +def set_inmanta_state_dir(inmanta_state_dir: str) -> None: + inmanta_config.state_dir.set(inmanta_state_dir) From 7481d7a95e0b59f625afba2fd2b39fdb44a81d26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 11:49:23 +0200 Subject: [PATCH 11/32] Bump inmanta-dev-dependencies from 2.21.0 to 2.22.0 (#301) Bumps [inmanta-dev-dependencies]() from 2.21.0 to 2.22.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1b8d334..3514c4c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.21.0; python_version > '3.6' +inmanta-dev-dependencies==2.22.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 962d315316f3a8f55de57192e7b6ba2fc62b159c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20K=C5=91v=C3=A1ri?= <55082127+andraskvr@users.noreply.github.com> Date: Wed, 15 Jun 2022 14:37:39 +0200 Subject: [PATCH 12/32] Clean up iso3 pipeline (#303) --- Jenkinsfile-integration-tests-iso3 | 60 ------------------------------ 1 file changed, 60 deletions(-) delete mode 100644 Jenkinsfile-integration-tests-iso3 diff --git a/Jenkinsfile-integration-tests-iso3 b/Jenkinsfile-integration-tests-iso3 deleted file mode 100644 index 0850ac8..0000000 --- a/Jenkinsfile-integration-tests-iso3 +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Test the pytest-inmanta version used by the ISO3 product (pytest-inmanta<1.5.0) against - * the corresponding inmanta-core version. - */ - pipeline { - agent any - triggers { - cron(BRANCH_NAME == "master" ? "H H(2-5) * * *": "") - } - - environment { - REPO_NAME="pytest-inmanta" - PIP_INDEX_URL="https://artifacts.internal.inmanta.com/inmanta/dev" - PIP_PRE="true" - } - - options { - disableConcurrentBuilds() - checkoutToSubdirectory(env.REPO_NAME) - skipDefaultCheckout() - buildDiscarder(logRotator(numToKeepStr: '30')) - } - - stages { - stage("Setup") { - steps { - deleteDir() - dir(env.REPO_NAME) { - checkout scm - script { - sh ''' - rm -rf ${WORKSPACE}/env - python3 -m venv ${WORKSPACE}/env - ${WORKSPACE}/env/bin/python3 -m pip install -U setuptools pip - - # Versions used by ISO3 - ${WORKSPACE}/env/bin/python3 -m pip install -U "pytest-inmanta<1.5.0" "inmanta~=2020.4.7" - ''' - } - } - } - } - - stage("Run tests") { - steps { - dir(env.REPO_NAME) { - sh ''' - ${WORKSPACE}/env/bin/python3 -m pytest --junitxml=junit.xml --log-cli-level DEBUG -s -vvv tests --basetemp=${WORKSPACE}/tmp - ''' - } - } - } - } - - post { - always { - junit "${env.REPO_NAME}/junit.xml" - } - } -} From f19ce39f2bc7b53ced84979f0e282a7a0adadaa0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jun 2022 11:49:24 +0200 Subject: [PATCH 13/32] Bump inmanta-dev-dependencies from 2.22.0 to 2.23.0 (#304) Bumps [inmanta-dev-dependencies]() from 2.22.0 to 2.23.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3514c4c..0af0c1f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.22.0; python_version > '3.6' +inmanta-dev-dependencies==2.23.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From b09146234f96d32261d95475d674c63d07465925 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 11:49:22 +0200 Subject: [PATCH 14/32] Bump inmanta-dev-dependencies from 2.23.0 to 2.24.0 (#305) Bumps [inmanta-dev-dependencies]() from 2.23.0 to 2.24.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0af0c1f..c298330 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.23.0; python_version > '3.6' +inmanta-dev-dependencies==2.24.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 6fe8cefa6165ae9562c89dbc1f3c175038a55dcb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Jul 2022 11:49:21 +0200 Subject: [PATCH 15/32] Bump inmanta-dev-dependencies from 2.24.0 to 2.25.0 (#307) Bumps [inmanta-dev-dependencies]() from 2.24.0 to 2.25.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c298330..59478fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.24.0; python_version > '3.6' +inmanta-dev-dependencies==2.25.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 0cbfb217e35e726820c78a906c2dc392b28b83b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Jul 2022 11:49:28 +0200 Subject: [PATCH 16/32] Bump inmanta-dev-dependencies from 2.25.0 to 2.26.0 (#308) Bumps [inmanta-dev-dependencies]() from 2.25.0 to 2.26.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 59478fc..c2b5ca1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.25.0; python_version > '3.6' +inmanta-dev-dependencies==2.26.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 82a2c4a3795b9a897413a5c49cd01e34d41b5379 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 17:03:05 +0200 Subject: [PATCH 17/32] Bump inmanta-dev-dependencies from 2.26.0 to 2.27.0 (#309) Bumps [inmanta-dev-dependencies]() from 2.26.0 to 2.27.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c2b5ca1..5aec582 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.26.0; python_version > '3.6' +inmanta-dev-dependencies==2.27.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 74704516a2392cb179c35c0c2ad0709924316e83 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 11:49:25 +0200 Subject: [PATCH 18/32] Bump inmanta-dev-dependencies from 2.27.0 to 2.29.0 (#310) Bumps [inmanta-dev-dependencies]() from 2.27.0 to 2.29.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5aec582..306ef55 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.27.0; python_version > '3.6' +inmanta-dev-dependencies==2.29.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From d61d790f8060c1bffb36d53ba0004e7c4962c0dd Mon Sep 17 00:00:00 2001 From: FloLey <95339363+FloLey@users.noreply.github.com> Date: Wed, 20 Jul 2022 16:40:15 +0200 Subject: [PATCH 19/32] issue/306: handle core's strict dependency check capabilities (#311) inmanta/inmanta-core#4276 introduced the option for strict dependency checking when installing modules. this commit adds support for enabling/disabling the checks in pytest-inmanta. The default should be to enable it (include a change entry that states this). closes #306 --- CHANGELOG.md | 2 + README.md | 1 + .../MANIFEST.in | 4 ++ .../testmodulev2conflict1/__init__.py | 11 ++++ .../model/_init.cf | 1 + .../pyproject.toml | 3 ++ .../setup.cfg | 14 +++++ .../MANIFEST.in | 4 ++ .../testmodulev2conflict2/__init__.py | 11 ++++ .../model/_init.cf | 1 + .../pyproject.toml | 3 ++ .../setup.cfg | 14 +++++ .../test_conflict_dependencies/files/.gitkeep | 0 .../test_conflict_dependencies/model/_init.cf | 0 .../test_conflict_dependencies/module.yml | 8 +++ .../plugins/__init__.py | 17 ++++++ .../requirements.dev.txt | 7 +++ .../requirements.txt | 2 + .../templates/.gitkeep | 0 .../tests/test_basics.py | 21 ++++++++ pytest_inmanta/parameters.py | 12 +++++ pytest_inmanta/plugin.py | 17 +++++- tests/test_dependencies.py | 54 +++++++++++++++++++ 23 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 examples/inmanta-module-testmodulev2conflict1/MANIFEST.in create mode 100644 examples/inmanta-module-testmodulev2conflict1/inmanta_plugins/testmodulev2conflict1/__init__.py create mode 100644 examples/inmanta-module-testmodulev2conflict1/model/_init.cf create mode 100644 examples/inmanta-module-testmodulev2conflict1/pyproject.toml create mode 100644 examples/inmanta-module-testmodulev2conflict1/setup.cfg create mode 100644 examples/inmanta-module-testmodulev2conflict2/MANIFEST.in create mode 100644 examples/inmanta-module-testmodulev2conflict2/inmanta_plugins/testmodulev2conflict2/__init__.py create mode 100644 examples/inmanta-module-testmodulev2conflict2/model/_init.cf create mode 100644 examples/inmanta-module-testmodulev2conflict2/pyproject.toml create mode 100644 examples/inmanta-module-testmodulev2conflict2/setup.cfg create mode 100644 examples/test_conflict_dependencies/files/.gitkeep create mode 100644 examples/test_conflict_dependencies/model/_init.cf create mode 100644 examples/test_conflict_dependencies/module.yml create mode 100644 examples/test_conflict_dependencies/plugins/__init__.py create mode 100644 examples/test_conflict_dependencies/requirements.dev.txt create mode 100644 examples/test_conflict_dependencies/requirements.txt create mode 100644 examples/test_conflict_dependencies/templates/.gitkeep create mode 100644 examples/test_conflict_dependencies/tests/test_basics.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 895da2b..28beb0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # v 2.4.0 (?) Changes in this release: - Add fixture to change the Inmanta state dir to a writable location for the current user. +- Add a new '--no-strict-deps-check' option to run pytest-inmanta using the legacy check on requirements. +By default the new strict check of core will be used. # v 2.3.3 (2022-05-18) Changes in this release: diff --git a/README.md b/README.md index 6dda23a..9dc7127 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ The following options are available. When not using this option during the testing of plugins with the `project.get_plugin_function` method, it's possible that the module's `plugin/__init__.py` is loaded multiple times, which can cause issues when it has side effects, as they are executed multiple times as well. + * `--no-strict-deps-check`: option to run pytest-inmanta using the legacy check(less strict) on requirements. By default the new strict will be used. Use the generic pytest options `--log-cli-level` to show Inmanta logger to see any setup or cleanup warnings. For example, `--log-cli-level=INFO` diff --git a/examples/inmanta-module-testmodulev2conflict1/MANIFEST.in b/examples/inmanta-module-testmodulev2conflict1/MANIFEST.in new file mode 100644 index 0000000..6a98ec9 --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict1/MANIFEST.in @@ -0,0 +1,4 @@ +include inmanta_plugins/testmodulev2conflict1/setup.cfg +recursive-include inmanta_plugins/testmodulev2conflict1/model *.cf +graft inmanta_plugins/testmodulev2conflict1/files +graft inmanta_plugins/testmodulev2conflict1/templates diff --git a/examples/inmanta-module-testmodulev2conflict1/inmanta_plugins/testmodulev2conflict1/__init__.py b/examples/inmanta-module-testmodulev2conflict1/inmanta_plugins/testmodulev2conflict1/__init__.py new file mode 100644 index 0000000..27fc562 --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict1/inmanta_plugins/testmodulev2conflict1/__init__.py @@ -0,0 +1,11 @@ +""" + Copyright 2021 Inmanta + Contact: code@inmanta.com + License: Apache 2.0 +""" +from inmanta.plugins import plugin + + +@plugin +def myplugin(x: "int") -> "int": + return x diff --git a/examples/inmanta-module-testmodulev2conflict1/model/_init.cf b/examples/inmanta-module-testmodulev2conflict1/model/_init.cf new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict1/model/_init.cf @@ -0,0 +1 @@ + diff --git a/examples/inmanta-module-testmodulev2conflict1/pyproject.toml b/examples/inmanta-module-testmodulev2conflict1/pyproject.toml new file mode 100644 index 0000000..9787c3b --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict1/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/examples/inmanta-module-testmodulev2conflict1/setup.cfg b/examples/inmanta-module-testmodulev2conflict1/setup.cfg new file mode 100644 index 0000000..1045f68 --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict1/setup.cfg @@ -0,0 +1,14 @@ +[metadata] +name = inmanta-module-testmodulev2conflict1 +freeze_recursive = False +freeze_operator = ~= +version = 0.1 +license = Test License + +[options] +install_requires = + inmanta-module-std + lorem~=0.0.1 +zip_safe = False +include_package_data = True +packages = find_namespace: diff --git a/examples/inmanta-module-testmodulev2conflict2/MANIFEST.in b/examples/inmanta-module-testmodulev2conflict2/MANIFEST.in new file mode 100644 index 0000000..8516475 --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict2/MANIFEST.in @@ -0,0 +1,4 @@ +include inmanta_plugins/testmodulev2conflict2/setup.cfg +recursive-include inmanta_plugins/testmodulev2conflict2/model *.cf +graft inmanta_plugins/testmodulev2conflict2/files +graft inmanta_plugins/testmodulev2conflict2/templates diff --git a/examples/inmanta-module-testmodulev2conflict2/inmanta_plugins/testmodulev2conflict2/__init__.py b/examples/inmanta-module-testmodulev2conflict2/inmanta_plugins/testmodulev2conflict2/__init__.py new file mode 100644 index 0000000..27fc562 --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict2/inmanta_plugins/testmodulev2conflict2/__init__.py @@ -0,0 +1,11 @@ +""" + Copyright 2021 Inmanta + Contact: code@inmanta.com + License: Apache 2.0 +""" +from inmanta.plugins import plugin + + +@plugin +def myplugin(x: "int") -> "int": + return x diff --git a/examples/inmanta-module-testmodulev2conflict2/model/_init.cf b/examples/inmanta-module-testmodulev2conflict2/model/_init.cf new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict2/model/_init.cf @@ -0,0 +1 @@ + diff --git a/examples/inmanta-module-testmodulev2conflict2/pyproject.toml b/examples/inmanta-module-testmodulev2conflict2/pyproject.toml new file mode 100644 index 0000000..9787c3b --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict2/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/examples/inmanta-module-testmodulev2conflict2/setup.cfg b/examples/inmanta-module-testmodulev2conflict2/setup.cfg new file mode 100644 index 0000000..e1d82d1 --- /dev/null +++ b/examples/inmanta-module-testmodulev2conflict2/setup.cfg @@ -0,0 +1,14 @@ +[metadata] +name = inmanta-module-testmodulev2conflict2 +freeze_recursive = False +freeze_operator = ~= +version = 0.1 +license = Test License + +[options] +install_requires = + inmanta-module-std + lorem~=0.1.1 +zip_safe = False +include_package_data = True +packages = find_namespace: diff --git a/examples/test_conflict_dependencies/files/.gitkeep b/examples/test_conflict_dependencies/files/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/examples/test_conflict_dependencies/model/_init.cf b/examples/test_conflict_dependencies/model/_init.cf new file mode 100644 index 0000000..e69de29 diff --git a/examples/test_conflict_dependencies/module.yml b/examples/test_conflict_dependencies/module.yml new file mode 100644 index 0000000..aa2164b --- /dev/null +++ b/examples/test_conflict_dependencies/module.yml @@ -0,0 +1,8 @@ +author: Inmanta +author_email: code@inmanta.com +description: module that test what happens when its dependencies conflict +license: ASL 2.0 +copyright: 2021 Inmanta +name: test_conflict_dependencies +version: 0.0.1 +compiler_version: 2019.3 diff --git a/examples/test_conflict_dependencies/plugins/__init__.py b/examples/test_conflict_dependencies/plugins/__init__.py new file mode 100644 index 0000000..0e7ead4 --- /dev/null +++ b/examples/test_conflict_dependencies/plugins/__init__.py @@ -0,0 +1,17 @@ +""" + Copyright 2021 Inmanta + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Contact: code@inmanta.com +""" diff --git a/examples/test_conflict_dependencies/requirements.dev.txt b/examples/test_conflict_dependencies/requirements.dev.txt new file mode 100644 index 0000000..3db865a --- /dev/null +++ b/examples/test_conflict_dependencies/requirements.dev.txt @@ -0,0 +1,7 @@ +pytest-inmanta +flake8 +flake8-black +flake8-isort>3.0.0 +flake8-copyright +isort +black diff --git a/examples/test_conflict_dependencies/requirements.txt b/examples/test_conflict_dependencies/requirements.txt new file mode 100644 index 0000000..1ee09ae --- /dev/null +++ b/examples/test_conflict_dependencies/requirements.txt @@ -0,0 +1,2 @@ +inmanta-module-testmodulev2conflict1 +inmanta-module-testmodulev2conflict2 diff --git a/examples/test_conflict_dependencies/templates/.gitkeep b/examples/test_conflict_dependencies/templates/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/examples/test_conflict_dependencies/tests/test_basics.py b/examples/test_conflict_dependencies/tests/test_basics.py new file mode 100644 index 0000000..65e8053 --- /dev/null +++ b/examples/test_conflict_dependencies/tests/test_basics.py @@ -0,0 +1,21 @@ +""" + Copyright 2021 Inmanta + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Contact: code@inmanta.com +""" + + +def test_basics(project): + project.compile("import test_conflict_dependencies") diff --git a/pytest_inmanta/parameters.py b/pytest_inmanta/parameters.py index f6a25ab..f5a30df 100644 --- a/pytest_inmanta/parameters.py +++ b/pytest_inmanta/parameters.py @@ -63,6 +63,18 @@ group=param_group, ) +inm_no_strict_deps_check = BooleanTestParameter( + argument="--no-strict-deps-check", + environment_variable="INMANTA_NO_STRICT_DEPS_CHECKS", + usage=( + "Tell pytest-inmanta to run without using the deps check after module installation." + " When using the dependency check, an error is raised if there are conflicting requirements" + " when disabling the check, the less strict legacy behavior is used instead." + ), + default=False, + group=param_group, +) + # This is the legacy module repo option # TODO remove this in next major version bump diff --git a/pytest_inmanta/plugin.py b/pytest_inmanta/plugin.py index b45aede..54eb132 100644 --- a/pytest_inmanta/plugin.py +++ b/pytest_inmanta/plugin.py @@ -73,6 +73,7 @@ def mktemp(self, path: str) -> py.path.local: inm_mod_in_place, inm_mod_repo, inm_no_load_plugins, + inm_no_strict_deps_check, inm_venv, ) from .test_parameter import ParameterNotSetException, TestParameterRegistry @@ -281,7 +282,9 @@ def project_factory(request: pytest.FixtureRequest) -> typing.Callable[[], "Proj def create_project(**kwargs: object): load_plugins = not inm_no_load_plugins.resolve(request.config) + no_strict_deps_check = inm_no_strict_deps_check.resolve(request.config) extended_kwargs: typing.Dict[str, object] = { + "no_strict_deps_check": no_strict_deps_check, "load_plugins": load_plugins, "env_path": env_dir, **kwargs, @@ -605,6 +608,7 @@ def __init__( project_dir: str, env_path: str, load_plugins: typing.Optional[bool] = True, + no_strict_deps_check: typing.Optional[bool] = False, ) -> None: """ :param project_dir: Directory containing the Inmanta project. @@ -613,6 +617,7 @@ def __init__( """ self._test_project_dir = project_dir self._env_path = env_path + self.no_strict_deps_check = no_strict_deps_check self._stdout: typing.Optional[str] = None self._stderr: typing.Optional[str] = None self.types: typing.Optional[typing.Dict[str, inmanta.ast.Type]] = None @@ -663,7 +668,7 @@ def init(self, capsys: "CaptureFixture") -> None: def _create_project_and_load(self, model: str) -> module.Project: """ - This method doesn the following: + This method does the following: * Add the given model file to the Inmanta project * Install the module dependencies * Load the project @@ -678,12 +683,20 @@ def _create_project_and_load(self, model: str) -> module.Project: module.Project.__init__ ) # The venv_path parameter only exists on ISO5+ + extra_kwargs_init = ( {"venv_path": self._env_path} if "venv_path" in signature_init.parameters.keys() else {} ) - test_project = module.Project(self._test_project_dir, **extra_kwargs_init) + + if "strict_deps_check" in signature_init.parameters.keys(): + extra_kwargs_init["strict_deps_check"] = not self.no_strict_deps_check + + test_project = module.Project( + self._test_project_dir, + **extra_kwargs_init, + ) ProjectLoader.load(test_project) diff --git a/tests/test_dependencies.py b/tests/test_dependencies.py index 6d68ed1..70b73cf 100644 --- a/tests/test_dependencies.py +++ b/tests/test_dependencies.py @@ -20,6 +20,8 @@ import os import tempfile +import pytest + import pytest_inmanta.plugin import utils from inmanta import env @@ -54,3 +56,55 @@ def test_transitive_v2_dependencies(examples_v2_package_index, pytestconfig, tes result.assert_outcomes(passed=1) finally: utils.unload_modules_for_path(venv.site_packages_dir) + + +@pytest.mark.parametrize( + "no_strict_deps_check, error_msg", + [ + (True, "CompilerException"), + (False, "ConflictingRequirements"), + ], +) +def test_conflicing_dependencies( + examples_v2_package_index, pytestconfig, testdir, no_strict_deps_check, error_msg +): + """ + when using the pytest-inmanta without specifying the --no-strict-deps-check, the constraints + of the installed modules/packages are verified and if a conflict is detected a ConflictingRequirement + error is raised. + when using pytest-inmanta with --no-strict-deps-check option, + the legacy check on the constraints is done. If the installed modules are not compatible + a CompilerException is raised. In the used example for this test, + test_conflict_dependencies(v1 module) requires inmanta-module-testmodulev2conflict1 and + inmanta-module-testmodulev2conflict2. The later two are incompatible as one requires lorem 0.0.1 + and the other one 0.1.1. + """ + # set working directory to allow in-place with all example modules + pytest_inmanta.plugin.CURDIR = str( + pytestconfig.rootpath / "examples" / "test_conflict_dependencies" + ) + testdir.copy_example("test_conflict_dependencies") + + with tempfile.TemporaryDirectory() as venv_dir: + # set up environment + venv: env.VirtualEnv = env.VirtualEnv(env_path=venv_dir) + try: + venv.use_virtual_env() + + # run tests + result = testdir.runpytest_inprocess( + "tests/test_basics.py", + *(["--no-strict-deps-check"] if no_strict_deps_check else []), + "--use-module-in-place", + # add pip index containing examples packages as module repo + "--module_repo", + f"package:{examples_v2_package_index}", + # include configured pip index for inmanta-module-std and lorem + "--module_repo", + "package:" + + os.environ.get("PIP_INDEX_URL", "package:https://pypi.org/simple"), + ) + result.assert_outcomes(errors=1) + assert error_msg in "\n".join(result.outlines) + finally: + utils.unload_modules_for_path(venv.site_packages_dir) From 0266ee034b85af9ddbec7f360087c57b32463abd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Jul 2022 11:49:11 +0200 Subject: [PATCH 20/32] Bump inmanta-dev-dependencies from 2.29.0 to 2.30.0 (#312) Bumps [inmanta-dev-dependencies]() from 2.29.0 to 2.30.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 306ef55..42d2e53 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.29.0; python_version > '3.6' +inmanta-dev-dependencies==2.30.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 225794936253686fef9803cfd55a294884284a0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 11:49:30 +0200 Subject: [PATCH 21/32] Bump inmanta-dev-dependencies from 2.30.0 to 2.31.0 (#313) Bumps [inmanta-dev-dependencies]() from 2.30.0 to 2.31.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 42d2e53..953f084 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.30.0; python_version > '3.6' +inmanta-dev-dependencies==2.31.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From f486dd9bcc8f85c95daa831dbb77f841b0f738fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Aug 2022 11:49:34 +0200 Subject: [PATCH 22/32] Bump inmanta-dev-dependencies from 2.31.0 to 2.32.0 (#314) Bumps [inmanta-dev-dependencies]() from 2.31.0 to 2.32.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 953f084..83919d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.31.0; python_version > '3.6' +inmanta-dev-dependencies==2.32.0; python_version > '3.6' inmanta-core pydantic==1.9.1 pyyaml==6.0 From 156214ae6712ae0bcb3cbe7013725b4149bff326 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Aug 2022 09:57:11 +0200 Subject: [PATCH 23/32] Bump pydantic from 1.9.1 to 1.9.2 (#317) Bumps [pydantic](https://github.com/samuelcolvin/pydantic) from 1.9.1 to 1.9.2. - [Release notes](https://github.com/samuelcolvin/pydantic/releases) - [Changelog](https://github.com/pydantic/pydantic/blob/v1.9.2/HISTORY.md) - [Commits](https://github.com/samuelcolvin/pydantic/compare/v1.9.1...v1.9.2) --- updated-dependencies: - dependency-name: pydantic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 83919d3..a5cb3c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' inmanta-dev-dependencies==2.32.0; python_version > '3.6' inmanta-core -pydantic==1.9.1 +pydantic==1.9.2 pyyaml==6.0 From 7914fb191a559b2d288551039385a5786a5a6443 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Aug 2022 11:49:10 +0200 Subject: [PATCH 24/32] Bump inmanta-dev-dependencies from 2.32.0 to 2.33.0 (#319) Bumps [inmanta-dev-dependencies]() from 2.32.0 to 2.33.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a5cb3c7..344e5dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.32.0; python_version > '3.6' +inmanta-dev-dependencies==2.33.0; python_version > '3.6' inmanta-core pydantic==1.9.2 pyyaml==6.0 From 927d80dbce8e5ecbf1a61150cf670454f58a09e3 Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 30 Aug 2022 13:26:16 +0200 Subject: [PATCH 25/32] Venv functions refactor (#320) * moved venv functions to utils * py36 compatible * pep8 --- tests/test_basic_example_v2.py | 66 ++++------------------------ tests/utils.py | 78 +++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 59 deletions(-) diff --git a/tests/test_basic_example_v2.py b/tests/test_basic_example_v2.py index 9de698a..92e9d91 100644 --- a/tests/test_basic_example_v2.py +++ b/tests/test_basic_example_v2.py @@ -16,13 +16,9 @@ Contact: code@inmanta.com """ import logging -import os -import subprocess # Note: These tests only function when the pytest output is not modified by plugins such as pytest-sugar! -import tempfile -from importlib.abc import Loader -from typing import Iterator, Optional, Tuple +from typing import Iterator import pytest @@ -43,68 +39,22 @@ def testmodulev2_venv(pytestconfig) -> Iterator[env.VirtualEnv]: """ Yields a Python environment with testmodulev2 installed in it. """ - with tempfile.TemporaryDirectory() as venv_dir: - # set up environment - venv: env.VirtualEnv = env.VirtualEnv(env_path=venv_dir) - venv.init_env() - venv_unset_python_path(venv) - # install test module into environment - subprocess.check_call( - [ - venv.python_path, - "-m", - "inmanta.app", - "-X", - "module", - "install", - str(pytestconfig.rootpath / "examples" / "testmodulev2"), - ], - ) + with utils.module_v2_venv( + pytestconfig.rootpath / "examples" / "testmodulev2" + ) as venv: yield venv -def venv_unset_python_path(venv: env.VirtualEnv) -> None: - """ - Workaround for pypa/build#405: unset PYTHONPATH because it's not required in this case and it triggers a bug in build - """ - sitecustomize_existing: Optional[ - Tuple[Optional[str], Loader] - ] = env.ActiveEnv.get_module_file("sitecustomize") - # inherit from existing sitecustomize.py - sitecustomize_inherit: str - if sitecustomize_existing is not None and sitecustomize_existing[0] is not None: - with open(sitecustomize_existing[0], "r") as fd: - sitecustomize_inherit = fd.read() - else: - sitecustomize_inherit = "" - with open(os.path.join(venv.site_packages_dir, "sitecustomize.py"), "a") as fd: - fd.write( - f""" -{sitecustomize_inherit} - -import os - -if "PYTHONPATH" in os.environ: - del os.environ["PYTHONPATH"] - """.strip() - ) - - @pytest.fixture(scope="function") def testmodulev2_venv_active( - deactive_venv, testmodulev2_venv + deactive_venv: None, + testmodulev2_venv: env.VirtualEnv, ) -> Iterator[env.VirtualEnv]: """ Activates a Python environment with testmodulev2 installed in it for the currently running process. """ - with tempfile.TemporaryDirectory() as tmpdir: - # Create a unique function-scoped venv dir to prevent caching issues with inmanta_plugins' submodule_search_locations - unique_env_dir: str = os.path.join(tmpdir, ".env") - os.symlink(testmodulev2_venv.env_path, unique_env_dir) - unique_env: env.VirtualEnv = env.VirtualEnv(env_path=unique_env_dir) - unique_env.use_virtual_env() - yield unique_env - utils.unload_modules_for_path(unique_env.site_packages_dir) + with utils.activate_venv(testmodulev2_venv) as venv: + yield venv def test_basic_example(testdir, caplog, testmodulev2_venv_active): diff --git a/tests/utils.py b/tests/utils.py index 923b47e..72eb559 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -16,10 +16,86 @@ Contact: code@inmanta.com """ +import contextlib import importlib +import os +import subprocess import sys +import tempfile +from importlib.abc import Loader from types import ModuleType -from typing import Optional, Sequence +from typing import Iterator, Optional, Sequence, Tuple + +from inmanta import env + + +@contextlib.contextmanager +def module_v2_venv(module_path: str) -> Iterator[env.VirtualEnv]: + """ + Yields a Python environment with the given module installed in it. + """ + with tempfile.TemporaryDirectory() as venv_dir: + # set up environment + venv: env.VirtualEnv = env.VirtualEnv(env_path=venv_dir) + venv.init_env() + venv_unset_python_path(venv) + # install test module into environment + subprocess.check_call( + [ + venv.python_path, + "-m", + "inmanta.app", + "-X", + "module", + "install", + module_path, + ], + ) + yield venv + + +@contextlib.contextmanager +def activate_venv(venv: env.VirtualEnv) -> Iterator[env.VirtualEnv]: + """ + Activates a given Python environment for the currently running process. To prevent + """ + with tempfile.TemporaryDirectory() as tmpdir: + # Create a unique venv dir to prevent caching issues with inmanta_plugins' submodule_search_locations + unique_env_dir: str = os.path.join(tmpdir, ".env") + os.symlink(venv.env_path, unique_env_dir) + unique_env: env.VirtualEnv = env.VirtualEnv(env_path=unique_env_dir) + unique_env.use_virtual_env() + try: + yield unique_env + finally: + unload_modules_for_path(unique_env.site_packages_dir) + + +def venv_unset_python_path(venv: env.VirtualEnv) -> None: + """ + Workaround for pypa/build#405: unset PYTHONPATH because it's not required in this case and it triggers a bug in build + """ + sitecustomize_existing: Optional[ + Tuple[Optional[str], Loader] + ] = env.ActiveEnv.get_module_file("sitecustomize") + # inherit from existing sitecustomize.py + sitecustomize_inherit: str + if sitecustomize_existing is not None and sitecustomize_existing[0] is not None: + with open(sitecustomize_existing[0], "r") as fd: + sitecustomize_inherit = fd.read() + else: + sitecustomize_inherit = "" + with open(os.path.join(venv.site_packages_dir, "sitecustomize.py"), "a") as fd: + fd.write( + f""" +{sitecustomize_inherit} + +import os + +if "PYTHONPATH" in os.environ: + del os.environ["PYTHONPATH"] + """.strip() + ) def unload_modules_for_path(path: str) -> None: From 7fe19a72c846ed48e7e0bb5a6c130f98ada2fba3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:03:27 +0200 Subject: [PATCH 26/32] Bump pydantic from 1.9.2 to 1.10.1 (#322) * Bump pydantic from 1.9.2 to 1.10.1 Bumps [pydantic](https://github.com/pydantic/pydantic) from 1.9.2 to 1.10.1. - [Release notes](https://github.com/pydantic/pydantic/releases) - [Changelog](https://github.com/pydantic/pydantic/blob/main/HISTORY.md) - [Commits](https://github.com/pydantic/pydantic/compare/v1.9.2...v1.10.1) --- updated-dependencies: - dependency-name: pydantic dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * version split Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Wouter De Borger --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 344e5dc..36f3e31 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' inmanta-dev-dependencies==2.33.0; python_version > '3.6' inmanta-core -pydantic==1.9.2 +pydantic==1.9.2; python_version <= '3.6' +pydantic==1.10.1; python_version > '3.6' pyyaml==6.0 From f9febbdc1862c6837a02c61f0a25b878a9dd93fd Mon Sep 17 00:00:00 2001 From: Hugo-Inmanta <98876549+Hugo-Inmanta@users.noreply.github.com> Date: Fri, 2 Sep 2022 11:04:28 +0200 Subject: [PATCH 27/32] [DOC] escape angle brackets so that they are correctly displayed (#323) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dc7127..6024295 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ The following options are available. module to a temporary libs directory. It allows testing the current module against specific versions of dependent modules. Using this option can speed up the tests, because the module dependencies are not downloaded multiple times. * `--module-repo`: location to download modules from, overrides `INMANTA_MODULE_REPO`. The default value is the inmanta github organisation. - For versions of inmanta-core that support v2 modules, the repo accepts the format "[:]" with "type" the repository type as + For versions of inmanta-core that support v2 modules, the repo accepts the format "[\:]\" with "type" the repository type as defined in the project config documentation. If type is omitted, git is assumed. Multiple repos can be passed by space-separating them or by passing the parameter multiple times. * `--install-mode`: install mode to use for modules downloaded during this test, overrides `INMANTA_INSTALL_MODE`. From 082a5bac08d99fd82414ea5f26304131884b8724 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 5 Sep 2022 09:54:56 +0200 Subject: [PATCH 28/32] fixed flake8 considering examples as separate projects with separate black config (#324) * fixed flake8 considering examples as separate projects with separate black config * added pyproject.toml --- pyproject.toml | 0 setup.cfg | 2 ++ 2 files changed, 2 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e69de29 diff --git a/setup.cfg b/setup.cfg index c661822..8a21c15 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,8 @@ copyright-check=True copyright-author=Inmanta # C errors are not selected by default, so add them to the selection select = E,F,W,C,BLK,I +# make sure projects in examples dir are never considered as separate projects rather than depending on how check is invoked +black-config=pyproject.toml [isort] profile=black From f9104b4c27078591fe229f71b14fa01adf2acded Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Sep 2022 17:50:40 +0200 Subject: [PATCH 29/32] Bump inmanta-dev-dependencies from 2.33.0 to 2.34.0 (#325) Bumps [inmanta-dev-dependencies]() from 2.33.0 to 2.34.0. --- updated-dependencies: - dependency-name: inmanta-dev-dependencies dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 36f3e31..af16ebc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' -inmanta-dev-dependencies==2.33.0; python_version > '3.6' +inmanta-dev-dependencies==2.34.0; python_version > '3.6' inmanta-core pydantic==1.9.2; python_version <= '3.6' pydantic==1.10.1; python_version > '3.6' From 0efdd5ac41253e08c6fbd770d39e0efe0393022a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Sep 2022 11:49:16 +0200 Subject: [PATCH 30/32] Bump pydantic from 1.10.1 to 1.10.2 (#327) Bumps [pydantic](https://github.com/pydantic/pydantic) from 1.10.1 to 1.10.2. - [Release notes](https://github.com/pydantic/pydantic/releases) - [Changelog](https://github.com/pydantic/pydantic/blob/main/HISTORY.md) - [Commits](https://github.com/pydantic/pydantic/compare/v1.10.1...v1.10.2) --- updated-dependencies: - dependency-name: pydantic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index af16ebc..bb02024 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ inmanta-dev-dependencies==1.76.0; python_version <= '3.6' inmanta-dev-dependencies==2.34.0; python_version > '3.6' inmanta-core pydantic==1.9.2; python_version <= '3.6' -pydantic==1.10.1; python_version > '3.6' +pydantic==1.10.2; python_version > '3.6' pyyaml==6.0 From b27514aabfe2b785895686b0eaca5c2391a1daf9 Mon Sep 17 00:00:00 2001 From: Hugo-Inmanta <98876549+Hugo-Inmanta@users.noreply.github.com> Date: Tue, 6 Sep 2022 13:36:55 +0200 Subject: [PATCH 31/32] Issue/318 port venv cleanup fixture fixes from core (#326) * [FEAT] cleanup sys.meta_path between tests * [FEAT] port venv cleanup fixture fixes from core * [FIX] perform requested changes --- tests/conftest.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 3ba20bb..62109d5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -46,6 +46,8 @@ def deactive_venv(): old_os_path = os.environ.get("PATH", "") old_prefix = sys.prefix old_path = sys.path + old_meta_path = sys.meta_path.copy() + old_path_hooks = sys.path_hooks.copy() old_pythonpath = os.environ.get("PYTHONPATH", None) old_os_venv: Optional[str] = os.environ.get("VIRTUAL_ENV", None) old_working_set = pkg_resources.working_set @@ -55,6 +57,13 @@ def deactive_venv(): os.environ["PATH"] = old_os_path sys.prefix = old_prefix sys.path = old_path + # reset sys.meta_path because it might contain finders for editable installs, make sure to keep the same object + sys.meta_path.clear() + sys.meta_path.extend(old_meta_path) + sys.path_hooks.clear() + sys.path_hooks.extend(old_path_hooks) + # Clear cache for sys.path_hooks + sys.path_importer_cache.clear() pkg_resources.working_set = old_working_set # Restore PYTHONPATH if old_pythonpath is not None: From b59f509bcf3e2389cad6904bec89ad0eb6010a63 Mon Sep 17 00:00:00 2001 From: inmantaci Date: Wed, 7 Sep 2022 08:25:34 +0200 Subject: [PATCH 32/32] set release date: 2022-09-07 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28beb0a..8b09c2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# v 2.4.0 (?) +# v 2.4.0 (2022-09-07) Changes in this release: - Add fixture to change the Inmanta state dir to a writable location for the current user. - Add a new '--no-strict-deps-check' option to run pytest-inmanta using the legacy check on requirements.