-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
fix issue #1618 by considering plugin args first #1673
Conversation
d1702bd
to
5e31ef7
Compare
@@ -352,6 +352,24 @@ def test_inifilename(self, tmpdir): | |||
assert config.inicfg.get('name') == 'value' | |||
assert config.inicfg.get('should_not_be_set') is None | |||
|
|||
def test_consider_plugin(self, testdir): | |||
pytest.importorskip('xdist') | |||
print testdir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like that shouldn't be here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what broke all Py3 builds. 😁
@@ -352,6 +352,24 @@ def test_inifilename(self, tmpdir): | |||
assert config.inicfg.get('name') == 'value' | |||
assert config.inicfg.get('should_not_be_set') is None | |||
|
|||
def test_consider_plugin(self, testdir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention #1618 on the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, when creating commit messages you can add a line "Fix #1618" so it closes the issue automatically when merged.
additionally prevent unnecessary importation of blocked plugins
5e31ef7
to
3c246f5
Compare
@The-Compiler @nicoddemus take alook? |
@@ -3,7 +3,7 @@ | |||
|
|||
**Changes** | |||
|
|||
* | |||
* fix (`#1618`_): properly consider explicitly blocked plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could explain this in more detail here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear this is too "pytest-internal-specific" and users won't really know what's going on... suggestion:
Fix #1618: consider
--plugins
(-p
) option before loading installed plugins, so it can be used to disable
plugins with problems or incorrectly installed (by using-p no:<plugin name>
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first time I understand what this PR really solves 😆 👍
Other than my minor comment this looks 👍 to me! 😁 |
pass | ||
""", | ||
) | ||
testdir.inline_run( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should verify that the test runs OK, so -p
could effectively disable the problematic plugin. As it stands, the return of inline_run
is just being ignored.
I tried your branch with a small example similar to the test, this is what I get:
(Note I'm not using On master the same command line looks better:
Could you take a look at that? FWIW passing
|
Can you show the file content? |
Sorry I don't have them with me right now, but IIRC: # conftest.py
pytest_plugins = ['plugin']
# plugin.py
raise ValueError
# test_f.py
def test():
pass |
@@ -352,6 +352,25 @@ def test_inifilename(self, tmpdir): | |||
assert config.inicfg.get('name') == 'value' | |||
assert config.inicfg.get('should_not_be_set') is None | |||
|
|||
@pytest.mark.issue1618 | |||
def test_consider_plugin(self, testdir): | |||
pytest.importorskip('xdist') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test failed in CI, but only on xdist
tox environments: I think we should run this in all environments because while I understand this was initially reported and diagnosed with xdist, the problem is general to pytest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test itself requires xdist, since the bug is triggered in config.from_dictargs
its simply impossible to test it with normal pytest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the more interesting question is - why do these fail on ci, it works in my local test :/ i wonder where my environment is different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? I'm think I tested this fix on a virtual environment without xdist...
Oh yes, I remember, I got the same problem and tested your fix just by running py.test
, without passing -n1
. If it should be run in both environments, I guess we should parametrize this then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am certain that xdist is currently the only thing triggering the behavior
the problem in question is the worker process ignoring the 'no:foo' plugin spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am certain that xdist is currently the only thing triggering the behavior
Something is wrong then... just tested on a fresh environment, without any plugins.
master
λ py.test test_foo.py -p no:plugin
Traceback (most recent call last):
...
File "C:\Users\bruno\addopts-order\src\plugin.py", line 1, in <module>
raise ValueError
ValueError
RonnyPfannschmidt:fix-1618
λ py.test test_foo.py -p no:plugin
============================= test session starts =============================
platform win32 -- Python 2.7.11, pytest-2.10.0.dev1, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\bruno\addopts-order\src, inifile:
collected 1 items
test_foo.py .
========================== 1 passed in 0.01 seconds =========================
That was on Python 2.7.
the more interesting question is - why do these fail on ci, it works in my local test :/ i wonder where my environment is different
Should be res.ret
instead of res.res
, not sure why that passes for you.
I also executed your test on my new environment, and it passes if I don't have xdist
and don't pass -n1
(also changing to res.ret
):
import pytest
pytest_plugins = ['pytester']
def test_consider_plugin(testdir):
# pytest.importorskip('xdist')
print (testdir)
testdir.makepyfile(conftest="""
pytest_plugins = ['plugin']
""",
plugin="""
raise ImportError
""",
test_foo="""
def test():
pass
""",
)
res = testdir.inline_run(
#'-n1',
'-p', 'no:plugin')
assert res.ret == 0
λ py.test test_ronny.py
============================= test session starts =============================
platform win32 -- Python 2.7.11, pytest-2.10.0.dev1, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\bruno\addopts-order\src, inifile:
collected 1 items
test_ronny.py .
========================== 1 passed in 0.10 seconds ===========================
The same test fails on master as expected:
ImportError: Error importing plugin "plugin"
So I'm guessing there is something weird with your local environment.
Any news here @RonnyPfannschmidt? |
@nicoddemus didnt get to touch this one today, hope to get at it in the afternoon |
closing this one, the approach i picked is problematic and configuration construction is "tricky" |
additionally prevent unnecessary importation of blocked plugins