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
My Reason why it fails:
As I have 2 tests and none of them start with the not keyword, the execution comes to L#220(return eval(keywordexpr, {}, mapping)) eval() thinks the keywordexpr string provided contains a dictionary with test_bug as the dictionary name and test_data0 & test_data1 as the dictionary keys.
So, it matches test_bug with the mapping. This step returns a bool.
Now, it tries to access the key test_data0 on this bool (True[test_data0] | False[test_data0]) at which place it complains saying TypeError: 'bool' object is not subscriptable.
If I run pytest -k "test_bug[test_data0]", it works fine because L215-L216 gets executed.
If I run pytest -k "test_bug1 or test_bug2", it works fine.
If I run pytest -k "test_bug[test_data0] ", it fails.
Does this appear to be an issue when using pytest_generate_tests and the -k flag together? Is this a known issue)? Any suggestions would be appreciated.
Thanks,
Darshak
The text was updated successfully, but these errors were encountered:
I am generating testmethod names using
pytest_generate_tests
and then executing them with the keyword substring match (-k flag).Simplified Example:
2 tests with the following names are generated -
test_bug[test_data0]
andtest_bug[test_data1]
Error:
When I run these with
pytest -k "test_bug[test_data0] or test_bug[test_data1]"
, I get aTypeError: 'bool' object is not subscriptable
.Code:
https://github.com/pytest-dev/pytest/blob/master/_pytest/mark.py#L215-L220
My Reason why it fails:
As I have 2 tests and none of them start with the
not
keyword, the execution comes to L#220(return eval(keywordexpr, {}, mapping))
eval()
thinks thekeywordexpr
string provided contains a dictionary withtest_bug
as the dictionary name andtest_data0 & test_data1
as the dictionary keys.So, it matches
test_bug
with the mapping. This step returns a bool.Now, it tries to access the key
test_data0
on this bool (True[test_data0] | False[test_data0]) at which place it complains sayingTypeError: 'bool' object is not subscriptable
.If I run
pytest -k "test_bug[test_data0]"
, it works fine because L215-L216 gets executed.If I run
pytest -k "test_bug1 or test_bug2"
, it works fine.If I run
pytest -k "test_bug[test_data0] "
, it fails.Versions
OS version: OSX Sierra, Win7
Pytest version: pytest-2.6.4
Python Version: 3.4.4, 3.5.2
Does this appear to be an issue when using pytest_generate_tests and the -k flag together? Is this a known issue)? Any suggestions would be appreciated.
Thanks,
Darshak
The text was updated successfully, but these errors were encountered: