-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to disable plugin based on environment? #7675
Comments
If I understand correctly, you want to load the plugins, so that pytest accepts the flags, but you don't want them to actually run. This is not a normal scenario so there isn't any particular support for it. I think the best solution would be to just have the plugins behave appropriately (i.e. not crash) on PyPy. However if this is really not possible, some workarounds I can think of are:
|
Actually, that doesn't help in this particular situation, because the plugins can't even be installed. What I imagine is a framework that offers one or more of these features:
Actually, just the first feature would be sufficient, but I suspect that without the second feature, many users would find the enabled-by-default functionality annoying or even problemmatic. Features one and two could be achieved by decoupling a plugin's config from the pytest API. If each plugin was responsible to load its own config (or had its own section in config), the absence of a plugin would be unaffected by the presence of config for that plugin. Pytest could provide a generic interface, like The fact that almost all configuration is buried in a single setting "addopts" makes it non-obvious what the behavior is when the value is set in the environment and the config and the command-line and puts the burden on plugins to support settings that override settings at a broader scope. The first workaround won't work in this case because the plugins aren't installed. The second option doesn't exactly work because it needs to work across every project that might be affected (any project that may want to use pytest-black or pytest-mypy on pypy). I'll try the second option and create a generic plugin that does nothing but implement support for select command-line options. |
I've released jaraco.test 3.0, which has a pytest plugin that allows defining meaningless options in pyproject.toml. For example, the following toml will work to expect
|
Hi @jaraco,
This is actually the plugin's implementation choice, that they require an extra flag to be active. They could also optionally be enabled via config, which does not produce an error for unknown configs. About disabling the plugins, that's possible through all the different ways you listed:
Not sure, there's nothing that prevents a plugin to load its configuration from some other place, it's their choice. Of course, almost all plugins use the pytest config API as that's what plugins are supposed to do. Given that this is not a normal situation, I don't think it makes much sense for pytest to implement an alternative interface.
Not sure I follow, the precedence of each is well defined: command-line first, config second, env vars last.
Yeah I think this is the way to go. While I can see we adding a switch to pytest to transform unknown options into warnings instead of errors, I think this is not common enough to add a new switch to the already large list of configuration options we have.
Nice! This allows a escape hatch for others in the same situation as you (that I believe are a bit rare however). |
I made pytest-forwards-compatible for addopts options, but it's currently only useful for .ini/.cfg projects |
The technique in jaraco.test doesn't work (jaraco/jaraco.test#1), so I'm back to the drawing board. I'll check out pytest-forwards-compatible. |
Right, so plugins are advised to follow an approach that runs afoul of this issue. Since pytest advises plugins to solicit their config from command-line parameters, it becomes difficult to selectively provide that config. The "addopts" technique also dosen't allow overriding a value at a closer scope that was defined at a broader scope. That is, you can't define "PYTEST_ADDOPTS=--black" at the environment level then "pytest_addopts=--no-black" at the config level then "--black" at the command-line. More importantly, the absence of the plugin causes the whole test suite to break due to any of these settings. I think my next approach is going to be to provide a translator. To solicit settings for various plugins in separate sections of a config file and to only enable those settings when the plugin is available. I apologize for being unclear about the challenges I'm facing. I've long found the "addopts" approach to be clumsy but it's only now that its clumsiness is really affecting my ability to use pytest. I'm conflating several separate concerns:
|
Would be possible for pytest-black and pytest-mypy to add configuration options (in pytest.ini)? Then you can drop EDIT: hmm but I see now that probably doesn't apply to pytest-black and pytest-mypy, as they are more like linters that you want to run in separate pytest invocations, correct?
No worries, I agree
You mean command-line arguments here, correct? To be clear, ini options today don't emit an error when an unknown option is defined in
This is really up to each plugin to implement as they see fit, and not something pytest can really enforce, I think. For example, installing
That's interesting, but we probably would need a formal proposal to be able to discuss all the details. We should also continue to try to figure out if this can be implemented as a separate plugin, instead of putting directly into the core. |
I prefer to think of linters as just another class of test that are run as a matter of course when testing the code, enabled by default and disabled selectively if needed (such as through
I mean configuration generally, but since the recommendation is for plugin authors to solicit configuration from the command line and that's what plugin authors are doing, that's where it's problematic. |
In jaraco.test 3.1.1, I've created a plugin that appears to be working and I suspect isn't subject to the race conditions because it uses the pytest_load_initial_conftests hook. The implementation ultimately was pretty straightforward. This approach has the added advantage that supplying |
I tried using this technique for |
Is there a hook that can run before the |
I figured out an (ugly) hack (jaraco/jaraco.test@f92cf8f). |
Indeed I suspect pytest-cov does anything it can to get coverage started as early as possible, which makes sense. Let me comment back to some of your previous bullet points:
If I understand what you mean, I'm not sure how that would work. How would pytest know about a plugin configuration (and here I understand command-line flags) without the plugin being installed (that's what I get from "plugin presence", correct me if I'm wrong)? Do you have some idea on how that would work in practice?
I mentioned this a few times, but I don't seem to be getting my point across, sorry. When pytest loads a plugin, all it can do after that point is call hooks on the plugins. What plugins do in their hooks is decided by the authors, so some authors decide to enable their functionality somehow: a command-line flag ( To illustrate this, a plugin might decide to only do its functionality if a certain command-line flag is passed. A reasonable implementation is to skip installing its hooks entirely during def pytest_configure(config):
if config.getoption("myoption"):
config.pluginmanager.register(MyActualHooks()) This makes it clear that pytest cannot enforce the plugin to do anything by default: the author chose to only provide its functionality when Or do you mean by this that pytest should encourage plugins to always be on (in the docs for example), without relying on flags/environment/tools/etc? If that's the case I don't see that being practical or enforceable, there are just too many plugin variants for that to work.
That's possible already but we could extend even further. For example, a hook called very early that allows arbitrary code to disable other plugins, but we hit problem 1 again: unrecognized options will be a problem.
Can you detail this a bit more please? Sorry for the long post, but lets backtrack a bit. AFAIU the problem you are facing is:
Perhaps a solution would be to include a hook on pytest to let plugins decide how to deal with unknown command-line options (and possibly ini-options as well), instead of raising an error. The default implementation would continue to raise an error, but a user might override that to print a warning instead. That should be really simple to implement and flexible enough to solve the immediate problem you are having. Thoughts? |
Jason R. Coombs (35): Update to bionic for Travis. Correct comment about IPv6 workaround. Suppress warnings in pytest-flake8, pytest-black, and pytest-checkdocs. Prefer pytest-black to pytest-black-multipy Test against Windows and Mac Define a default pool_vm_image Remove tox-venv and tox-pip-version. Tox-venv is discouraged (tox-dev/tox-venv#48 (comment)) and tox-pip-version was only there to support tox-venv. venv is dead; long live virtualenv. Remove more references to tox-venv Add workaround for warning emitted when junitxml is used. Ref pytest-dev/pytest#6178. Include mypy for type checking during tests. Ensure virtualenv is upgraded when installing tox. Fixes jaraco/path#188. Run tests on prereleases of Python on Windows. Fixes jaraco/skeleton#17. Add workaround for python/mypy#8627. Fixes jaraco/skeleton#18. Add 'refresh.svg' demonstrating an example of refreshing a project with the latest skeleton. Ref #7. Move workaround for python/mypy#8627 to tox.ini, as adding it to setup.cfg prevents releases to PyPI. Fixes jaraco/skeleton#19. Update comment to reflect correct class name. Remove workaround for python/mypy#8627. Ref jaraco/skeleton#18. Add test capturing issue reported in bpo-40564 Create Github releases when releasing the package. Fixes jaraco/skeleton#23. Moved refresh.svg to another branch. Reference the animation from the docs. Ref jaraco/skeleton#7. Add the env var mapping too. Disable pytest-black and pytest-mypy on PyPy. Fixes jaraco/skeleton#22. Ref pytest-dev/pytest#7675. Bump black and blacken-docs to latest stable versions. Instead of creating a copy of a any zipfile passed to Path, simply augment the behavior by replacing the class with a subclass. Use enabled plugin configuration to enable mypy and black when the plugin is present. Ref jaraco/skeleton#22. Also enable flake8 and cov when the plugins are present. Add a docstring explaining how the source zipfile is mutated. Update changelog. Restore running under pytest (still unittest compatibility). ⚫ Fade to black. Add unit test for iterdir on file. Add unit test for invalid args to open binary. Add unit test capturing expectation that a subclass type should be retained during traversal. Ref #56. Path subclasses now retain their type during traversal. Ref #56. Add test capturing missed expectation when is_file is invoked on a name not in the zipfile. Ref #55. Correct behavior of is_file to return False for non-existent files. Also fix two broken tests. Fixes #55.
I wonder if it'd help to have something like a However, I guess all those would need to be Still, it might be a solution for the issues mentioned in this thread? I've certainly seen similar issues when I e.g. want to |
….0.1 Jason R. Coombs (21): Remove workaround for python/mypy#8627. Ref jaraco/skeleton#18. Create Github releases when releasing the package. Fixes jaraco/skeleton#23. Moved refresh.svg to another branch. Reference the animation from the docs. Ref jaraco/skeleton#7. Add the env var mapping too. Disable pytest-black and pytest-mypy on PyPy. Fixes jaraco/skeleton#22. Ref pytest-dev/pytest#7675. Bump black and blacken-docs to latest stable versions. Use enabled plugin configuration to enable mypy and black when the plugin is present. Ref jaraco/skeleton#22. Also enable flake8 and cov when the plugins are present. Add workflows for running tests. Ref jaraco/skeleton#24. Cut releases from Github Actions instead of Azure Pipelines. Ref jaraco/skeleton#24. Refresh docs to prefer Github Actions to Azure Pipelines. Ref jaraco/skeleton#24. Use RTD v2 config Test on Python 3.9. Skip 3.7 to avoid creating too many builds. Release on 3.9. Drop tests on Travis, Appveyor, and Azure Pipelines. use add-github-secrets, which infers the secrets needed from the github workflow. Use inline flags with local scope. Update changelog Rewrite alt_tz as proper fixture. Skip when tzset isn't available. Use 'after' to construct PeriodicCommand with a more predictable delay. Remove legacy note about Python version. In test_periodic_command, freeze time rather than sleeping to increase execution speed and reliability.
…21.5.0 Danny Shemesh (1): Added the keyrings.osx-keychain-keys backend, as discussed in jaraco/keyring#462 Dmitry Shachnev (2): Disable SecretService backend if org.freedesktop.secrets name is not available Disable KWallet backend if org.kde.kwalletd5 name is not available Jason R. Coombs (22): Create Github releases when releasing the package. Fixes jaraco/skeleton#23. Moved refresh.svg to another branch. Reference the animation from the docs. Ref jaraco/skeleton#7. Add the env var mapping too. Disable pytest-black and pytest-mypy on PyPy. Fixes jaraco/skeleton#22. Ref pytest-dev/pytest#7675. Bump black and blacken-docs to latest stable versions. Use enabled plugin configuration to enable mypy and black when the plugin is present. Ref jaraco/skeleton#22. Omit 'return None' as it's implied. Update changelog. Ref #463. Add type hints for KeyringBackend.get_password and .get_credential. I was hoping adding these hints would capture the missed expectation in #463, but alas, they do not. Wrap lines before 80 col. Reword to use imperative voice and give directions in order of execution. Clarify that only passwords created by an executable of Python are relevant. Also enable flake8 and cov when the plugins are present. Add workflows for running tests. Ref jaraco/skeleton#24. Cut releases from Github Actions instead of Azure Pipelines. Ref jaraco/skeleton#24. Refresh docs to prefer Github Actions to Azure Pipelines. Ref jaraco/skeleton#24. Use RTD v2 config Test on Python 3.9. Skip 3.7 to avoid creating too many builds. Release on 3.9. Drop tests on Travis, Appveyor, and Azure Pipelines. use add-github-secrets, which infers the secrets needed from the github workflow. Use inline flags with local scope. Require importlib_metadata 1.0 or later. Fixes #466. Update changelog. 21.4.1 was never released Josh Faust (1): Add a Security Considerations section to the README, with some info about possible issues with the macOS Keychain László Várady (1): Fix return type of KWallet get_credential()
Hugo (1): Fix AppVeyor typo Hugo van Kemenade (2): Spelling and capitalisation (#8) Link badge to PyPI rather than static image Jason R. Coombs (54): Python 3 only Expect flake8 3.6 or later and remove suppression of warnings from Flake8 prior to 3.6. Rely on pytest-checkdocs 1.2.3, eliminating workaround for docutils warning. Remove workaround for gitlab.com/PyCQA/flake8/issues/275, apparently no longer necessary. Bring coverage to 100% Rely on future-fstrings for Python 3.5 compatibility Restore support for Python 2.7 Normalize indentation Include keyring support from twine Rename 'build-docs' to simply 'docs' (matching more popular convention). Prefer 'path' to 'path.py' Cover Python 3.8 in Windows tests Update black in pre-commit and add blacken-docs. Test and release using Azure Pipelines Correct guidance on project creation. Rely on setuptools_scm 3.4 and setuptools 42. Now setup.py is optional. Remove setuptools from test environment. Finish dropping support for Python 2 (I hope). Normalize whitespace Revert "setup.cfg: let python-tag mirror python_requires" Fade to black Fix links Update to bionic for Travis. Correct comment about IPv6 workaround. Suppress warnings in pytest-flake8, pytest-black, and pytest-checkdocs. Prefer pytest-black to pytest-black-multipy Test against Windows and Mac Define a default pool_vm_image Remove tox-venv and tox-pip-version. Tox-venv is discouraged (tox-dev/tox-venv#48 (comment)) and tox-pip-version was only there to support tox-venv. venv is dead; long live virtualenv. Remove more references to tox-venv Add workaround for warning emitted when junitxml is used. Ref pytest-dev/pytest#6178. Include mypy for type checking during tests. Ensure virtualenv is upgraded when installing tox. Fixes jaraco/path#188. Run tests on prereleases of Python on Windows. Fixes jaraco/skeleton#17. Add workaround for python/mypy#8627. Fixes jaraco/skeleton#18. Add 'refresh.svg' demonstrating an example of refreshing a project with the latest skeleton. Ref #7. Move workaround for python/mypy#8627 to tox.ini, as adding it to setup.cfg prevents releases to PyPI. Fixes jaraco/skeleton#19. Remove workaround for python/mypy#8627. Ref jaraco/skeleton#18. Create Github releases when releasing the package. Fixes jaraco/skeleton#23. Moved refresh.svg to another branch. Reference the animation from the docs. Ref jaraco/skeleton#7. Add the env var mapping too. Disable pytest-black and pytest-mypy on PyPy. Fixes jaraco/skeleton#22. Ref pytest-dev/pytest#7675. Bump black and blacken-docs to latest stable versions. Use enabled plugin configuration to enable mypy and black when the plugin is present. Ref jaraco/skeleton#22. Also enable flake8 and cov when the plugins are present. Add workflows for running tests. Ref jaraco/skeleton#24. Cut releases from Github Actions instead of Azure Pipelines. Ref jaraco/skeleton#24. Refresh docs to prefer Github Actions to Azure Pipelines. Ref jaraco/skeleton#24. Use RTD v2 config Test on Python 3.9. Skip 3.7 to avoid creating too many builds. Release on 3.9. Drop tests on Travis, Appveyor, and Azure Pipelines. use add-github-secrets, which infers the secrets needed from the github workflow. Use inline flags with local scope. Remove compatibility code. Update badge Update changelog. Vincent Fazio (1): setup.cfg: let python-tag mirror python_requires johnthagen (1): Line wrap LICENSE file layday (1): Require toml extra for setuptools_scm (#12)
…version 3.1.0 Jason R. Coombs (36): Remove tox-venv and tox-pip-version. Tox-venv is discouraged (tox-dev/tox-venv#48 (comment)) and tox-pip-version was only there to support tox-venv. venv is dead; long live virtualenv. Remove more references to tox-venv Add workaround for warning emitted when junitxml is used. Ref pytest-dev/pytest#6178. Include mypy for type checking during tests. Ensure virtualenv is upgraded when installing tox. Fixes jaraco/path#188. Run tests on prereleases of Python on Windows. Fixes jaraco/skeleton#17. Add workaround for python/mypy#8627. Fixes jaraco/skeleton#18. Add 'refresh.svg' demonstrating an example of refreshing a project with the latest skeleton. Ref #7. Move workaround for python/mypy#8627 to tox.ini, as adding it to setup.cfg prevents releases to PyPI. Fixes jaraco/skeleton#19. Remove workaround for python/mypy#8627. Ref jaraco/skeleton#18. Create Github releases when releasing the package. Fixes jaraco/skeleton#23. Moved refresh.svg to another branch. Reference the animation from the docs. Ref jaraco/skeleton#7. Add the env var mapping too. Disable pytest-black and pytest-mypy on PyPy. Fixes jaraco/skeleton#22. Ref pytest-dev/pytest#7675. Bump black and blacken-docs to latest stable versions. Use enabled plugin configuration to enable mypy and black when the plugin is present. Ref jaraco/skeleton#22. Also enable flake8 and cov when the plugins are present. Fix mypy glitch on __path__. Add workflows for running tests. Ref jaraco/skeleton#24. Cut releases from Github Actions instead of Azure Pipelines. Ref jaraco/skeleton#24. Refresh docs to prefer Github Actions to Azure Pipelines. Ref jaraco/skeleton#24. Use RTD v2 config Test on Python 3.9. Skip 3.7 to avoid creating too many builds. Release on 3.9. Drop tests on Travis, Appveyor, and Azure Pipelines. use add-github-secrets, which infers the secrets needed from the github workflow. Use inline flags with local scope. Honor TOX_WORK_DIR if set. Workaround for tox-dev/tox#20. Fix badge Collapse skeleton history from archive/2020-12 Update skeleton description to describe the periodic collapse. Fixes #27. Enable automerge Add except_ decorator. Following move to Github actions, port the expected failing test also. 🧎♀️ Genuflect to the types. 🧎♀️ Genuflect to the types. Pass the GITHUB_ACTIONS
…on 5.3.0 Diego Elio Pettenò (1): Fix README (and thus long_description). Hugo (1): Fix AppVeyor typo Hugo van Kemenade (2): Spelling and capitalisation (#8) Link badge to PyPI rather than static image Jason R. Coombs (75): Add Tidelift template Rely on alabaster theme to support sidebar rendering. Use nicer, simpler phrasing Add support for automatic publishing of release notes Use technique for environment passing matching that found in jaraco/skeleton Move Tidelift token into Travis configuration Update badge URL Add funding reference to project List sidebars to avoid errors looking for template 't' Python 3 only Test/release on Python 3.8 Apply black to docs/conf.py Update black version and links Expect flake8 3.6 or later and remove suppression of warnings from Flake8 prior to 3.6. Rely on pytest-checkdocs 1.2.3, eliminating workaround for docutils warning. Remove workaround for gitlab.com/PyCQA/flake8/issues/275, apparently no longer necessary. Normalize indentation Include keyring support from twine Rename 'build-docs' to simply 'docs' (matching more popular convention). Prefer 'path' to 'path.py' Cover Python 3.8 in Windows tests Update black in pre-commit and add blacken-docs. Test and release using Azure Pipelines Correct guidance on project creation. Rely on setuptools_scm 3.4 and setuptools 42. Now setup.py is optional. Remove setuptools from test environment. Finish dropping support for Python 2 (I hope). Normalize whitespace Revert "setup.cfg: let python-tag mirror python_requires" Update to bionic for Travis. Correct comment about IPv6 workaround. Suppress warnings in pytest-flake8, pytest-black, and pytest-checkdocs. Prefer pytest-black to pytest-black-multipy Test against Windows and Mac Define a default pool_vm_image Remove tox-venv and tox-pip-version. Tox-venv is discouraged (tox-dev/tox-venv#48 (comment)) and tox-pip-version was only there to support tox-venv. venv is dead; long live virtualenv. Remove more references to tox-venv Add workaround for warning emitted when junitxml is used. Ref pytest-dev/pytest#6178. Include mypy for type checking during tests. Ensure virtualenv is upgraded when installing tox. Fixes jaraco/path#188. Run tests on prereleases of Python on Windows. Fixes jaraco/skeleton#17. Add workaround for python/mypy#8627. Fixes jaraco/skeleton#18. Add 'refresh.svg' demonstrating an example of refreshing a project with the latest skeleton. Ref #7. Move workaround for python/mypy#8627 to tox.ini, as adding it to setup.cfg prevents releases to PyPI. Fixes jaraco/skeleton#19. Remove workaround for python/mypy#8627. Ref jaraco/skeleton#18. Create Github releases when releasing the package. Fixes jaraco/skeleton#23. Moved refresh.svg to another branch. Reference the animation from the docs. Ref jaraco/skeleton#7. Add the env var mapping too. Disable pytest-black and pytest-mypy on PyPy. Fixes jaraco/skeleton#22. Ref pytest-dev/pytest#7675. Bump black and blacken-docs to latest stable versions. Use enabled plugin configuration to enable mypy and black when the plugin is present. Ref jaraco/skeleton#22. Also enable flake8 and cov when the plugins are present. Add workflows for running tests. Ref jaraco/skeleton#24. Cut releases from Github Actions instead of Azure Pipelines. Ref jaraco/skeleton#24. Refresh docs to prefer Github Actions to Azure Pipelines. Ref jaraco/skeleton#24. Use RTD v2 config Test on Python 3.9. Skip 3.7 to avoid creating too many builds. Release on 3.9. Drop tests on Travis, Appveyor, and Azure Pipelines. use add-github-secrets, which infers the secrets needed from the github workflow. Use inline flags with local scope. Honor TOX_WORK_DIR if set. Workaround for tox-dev/tox#20. Collapse skeleton history from archive/2020-12 Update skeleton description to describe the periodic collapse. Fixes #27. Enable automerge Automatically inject project name in docs heading. pre-commit autoupdate Rename 'Automated Tests' to simply 'tests' Add note about automatic merging of PRs and the requirements and limitations. Prefer pytest-enabler to jaraco.test Enable complexity limit. Fixes jaraco/skeleton#34. Add support for namespace packages. Closes jaraco/skeleton#40. Normalize indentation ⚫ Fade to black. Update changelog. Suppress test failures on Windows Use short link for issue Replace rwt with pip-run Sviatoslav Sydorenko (3): Replace pep517.build with build (#37) Use license_files instead of license_file in meta (#35) Use `extend-ignore` in flake8 config (#33) Vincent Fazio (1): setup.cfg: let python-tag mirror python_requires johnthagen (1): Line wrap LICENSE file layday (1): Require toml extra for setuptools_scm (#12)
…on 3.5.1 Brian Rutledge (1): Use shutil for rmtree Hugo (1): Fix AppVeyor typo Hugo van Kemenade (2): Spelling and capitalisation (#8) Link badge to PyPI rather than static image Jason R. Coombs (74): Python 3 only Cover Python 3.8 in Windows tests Update black in pre-commit and add blacken-docs. Test and release using Azure Pipelines Correct guidance on project creation. Rely on setuptools_scm 3.4 and setuptools 42. Now setup.py is optional. Remove setuptools from test environment. Finish dropping support for Python 2 (I hope). Normalize whitespace Revert "setup.cfg: let python-tag mirror python_requires" Update to bionic for Travis. Correct comment about IPv6 workaround. Suppress warnings in pytest-flake8, pytest-black, and pytest-checkdocs. Prefer pytest-black to pytest-black-multipy Test against Windows and Mac Define a default pool_vm_image Remove tox-venv and tox-pip-version. Tox-venv is discouraged (tox-dev/tox-venv#48 (comment)) and tox-pip-version was only there to support tox-venv. venv is dead; long live virtualenv. Remove more references to tox-venv Add workaround for warning emitted when junitxml is used. Ref pytest-dev/pytest#6178. Include mypy for type checking during tests. Ensure virtualenv is upgraded when installing tox. Fixes jaraco/path#188. Run tests on prereleases of Python on Windows. Fixes jaraco/skeleton#17. Add workaround for python/mypy#8627. Fixes jaraco/skeleton#18. Add 'refresh.svg' demonstrating an example of refreshing a project with the latest skeleton. Ref #7. Move workaround for python/mypy#8627 to tox.ini, as adding it to setup.cfg prevents releases to PyPI. Fixes jaraco/skeleton#19. Remove workaround for python/mypy#8627. Ref jaraco/skeleton#18. Create Github releases when releasing the package. Fixes jaraco/skeleton#23. Moved refresh.svg to another branch. Reference the animation from the docs. Ref jaraco/skeleton#7. Add the env var mapping too. Disable pytest-black and pytest-mypy on PyPy. Fixes jaraco/skeleton#22. Ref pytest-dev/pytest#7675. Bump black and blacken-docs to latest stable versions. Use enabled plugin configuration to enable mypy and black when the plugin is present. Ref jaraco/skeleton#22. Also enable flake8 and cov when the plugins are present. Add workflows for running tests. Ref jaraco/skeleton#24. Cut releases from Github Actions instead of Azure Pipelines. Ref jaraco/skeleton#24. Refresh docs to prefer Github Actions to Azure Pipelines. Ref jaraco/skeleton#24. Use RTD v2 config 🧎♀️ Genuflect to the types. Remove compatibility code. Update changelog. Test on Python 3.9. Skip 3.7 to avoid creating too many builds. Release on 3.9. Drop tests on Travis, Appveyor, and Azure Pipelines. use add-github-secrets, which infers the secrets needed from the github workflow. Use inline flags with local scope. Honor TOX_WORK_DIR if set. Workaround for tox-dev/tox#20. Collapse skeleton history from archive/2020-12 Update skeleton description to describe the periodic collapse. Fixes #27. Enable automerge Add trim methods to WordSet 🧎♀️ Genuflect to the types. Automatically inject project name in docs heading. pre-commit autoupdate Rename 'Automated Tests' to simply 'tests' Add note about automatic merging of PRs and the requirements and limitations. Prefer pytest-enabler to jaraco.test Enable complexity limit. Fixes jaraco/skeleton#34. Add support for namespace packages. Closes jaraco/skeleton#40. Normalize indentation Rely on PEP 420 for namespace package Update changelog. Exclude dist from discovered packages. Fixes jaraco/skeleton#46. It's no longer necessary to filter this warning and it's not a warning anymore. Bump minimum pytest Require twine 3 with keyring unconditionally required. Add comments indicating why the exclusions are present Exclude mypy on Python 3.10 as workaround for python/typed_ast#156. Bump minimums on pytest-checkdocs and pytest-enabler as found on Setuptools. Also deny black on Python 3.10 as workaround for python/typed_ast#156. Add leading */ to coverage.run.omit. Workaround for pytest-dev/pytest-cov#456. Remove automerge. Fixes jaraco/skeleton#49. Enable dependabot (#50) Replace md file with badge linking to documentation site. Fixes jaraco/skeleton#47. Test on Python 3.10 Remove setup_requires, obviated by build-requires in pyproject.toml. Suppress deprecation warnings in flake8 and packaging.tags. Ref pypa/packaging#433. Fix syntax for in_. Closes #5. KOLANICH (1): Added an .editorconfig. Pull request jaraco/skeleton#43. Sviatoslav Sydorenko (4): Replace pep517.build with build (#37) Use license_files instead of license_file in meta (#35) Use `extend-ignore` in flake8 config (#33) Make sphinx fail on any warnings (#36) Vincent Fazio (1): setup.cfg: let python-tag mirror python_requires johnthagen (1): Line wrap LICENSE file layday (1): Require toml extra for setuptools_scm (#12)
In python/typed_ast#144, I confirmed that typed_ast, and by extension pytest-black and pytest-mypy, are not supported on PyPy (and cause crashes on installation). I'd like to fashion a technique that reflects this limitation and bypasses the installation and enabling of these plugins when testing on PyPy.
I've found I can selectively include or exclude the plugin modules by adding environment markers to the requirement:
However, these plugins require a two-step installation process:
--black
or--mypy
during pytest invocation.Leaving the
--<plugin>
inpytest.ini
(example) while deselecting the plugin for installation results in an InvocationError:Best I can tell, there's no easy way to programmatically disable the plugin (or only enable it if present).
In pytest-dev/pytest-cov#418, I encountered a similar problem where it was suitable to install coverage but its presence needed to be disabled at runtime. The workaround for that approach was specifically tuned to implementation details of that plugin.
What I'd really like is a uniform way for plugins to declare there presence, for them to be enabled by default, and layers of configuration (global, system, user, environment, invocation) where the enabling of that feature can be toggled on or off based on certain factors (maybe environment markers or maybe arbitrary Python logic).
But thinking short-term, are there any options available to selectively disable the enabling of the black and mypy plugins, such that they're enabled by default, but disabled when the environment is built on PyPy?
The text was updated successfully, but these errors were encountered: