You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed a confusing situation that occurs when I write a test that is decorated with a marker that has the same name as an argvalue I pass in to the parametrize marker for that test when run with -m <marker>. Hard to explain, but super easy to reliably demonstrate. I'm seeing this on pytest 3.0.7 (Python 3.5.2, Mac OS X 10.12.4):
Running pytest -vs --collect-only shows both tests selected. On the other hand, running pytest -vs --collect-only -m cluster will deselect the test_one[cluster] item and leave me only with the test_one[standalone].
To try to debug what's happening, I used the pytest_collection_modifyitems hook in a local conftest.py to print the keywords.keys() attribute for each item collected. That is,
# conftest.py
def pytest_collection_modifyitems(items):
for item in items:
print(item.keywords.keys())
The output when re-running my test (whether with or without the -m cluster shows the following keys:
In other words, it looks as if duplicate marker/parametrize ids are being deleted at some point, which causes the test to be deselected.
I've tracked down that this is happening at the marker and id level as the following snippet works around the error: @pytest.mark.parametrize('mode', ('cluster', 'standalone'), ids=('cluster_', 'standalone')).
The text was updated successfully, but these errors were encountered:
dimaspivak
changed the title
Test deselected if marker name matches argvalue
Test deselected if marker name matches parametrize id
May 13, 2017
Dang. Well thanks for the explanation, @RonnyPfannschmidt; I really appreciate you taking the time to respond (and to be awesome on the project in general 😄 ).
that was the least i could do, fixing the inner details of mark to resolve such strange edge-cases will take quite a while - so atm all we can do is explain the issues as issues and fix them
I've noticed a confusing situation that occurs when I write a test that is decorated with a marker that has the same name as an argvalue I pass in to the parametrize marker for that test when run with
-m <marker>
. Hard to explain, but super easy to reliably demonstrate. I'm seeing this onpytest 3.0.7
(Python 3.5.2
, Mac OS X 10.12.4):Running
pytest -vs --collect-only
shows both tests selected. On the other hand, runningpytest -vs --collect-only -m cluster
will deselect thetest_one[cluster]
item and leave me only with thetest_one[standalone]
.To try to debug what's happening, I used the
pytest_collection_modifyitems
hook in a localconftest.py
to print thekeywords.keys()
attribute for each item collected. That is,The output when re-running my test (whether with or without the
-m cluster
shows the following keys:In other words, it looks as if duplicate marker/parametrize ids are being deleted at some point, which causes the test to be deselected.
I've tracked down that this is happening at the marker and id level as the following snippet works around the error:
@pytest.mark.parametrize('mode', ('cluster', 'standalone'), ids=('cluster_', 'standalone'))
.The text was updated successfully, but these errors were encountered: