Skip to content
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

-k cannot handle strings containing spaces that start with a number #2936

Closed
dnut opened this issue Nov 17, 2017 · 1 comment
Closed

-k cannot handle strings containing spaces that start with a number #2936

dnut opened this issue Nov 17, 2017 · 1 comment

Comments

@dnut
Copy link

dnut commented Nov 17, 2017

Windows 10 x64
Python v2.7.14:84471935ed, Sep 16 2017, 20:25:58
pytest 3.2.3

I have some test methods named test_01_login_subscribe and test_02_failed_subscription (among others with different numbers). If I want to run the first, I can execute either of the following commands and it will only run test_01_login_subscribe. The same idea applies to the second test.

pytest -k test_01
pytest -k 01

I can also run both tests and no others by using one of these commands:

pytest -k "test_01 or test_02"
pytest -k "_01 or _02"

The following command, however, does not work. When I run this command, every single test in my suite is triggered:

pytest -k "01 or 02"

The following commands raise an exception:

pytest2 -k "01_ or 02_"
pytest2 -k "01_login_subscribe or 02_failed_subscription"

Here is the full output for the above command:

============================= test session starts =============================
platform win32 -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0 -- c:\python27\python.exe
cachedir: .cache
rootdir: C:\...\test, inifile: pytest.ini
collected 52 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\main.py", line 110, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\main.py", line 145, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\main.py", line 155, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\main.py", line 648, in perform_collect
INTERNALERROR>     config=self.config, items=items)
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\mark.py", line 151, in pytest_collection_modifyitems
INTERNALERROR>     if keywordexpr and not matchkeyword(colitem, keywordexpr):
INTERNALERROR>   File "c:\python27\lib\site-packages\_pytest\mark.py", line 234, in matchkeyword
INTERNALERROR>     return eval(keywordexpr, {}, mapping)
INTERNALERROR>   File "<string>", line 1
INTERNALERROR>     01_login_subscribe or 02_failed_subscription
INTERNALERROR>                      ^
INTERNALERROR> SyntaxError: invalid syntax
@dnut dnut changed the title -k option matches anything with strings starting with numbers -k option matches strings starting with numbers with all tests Nov 18, 2017
@dnut dnut changed the title -k option matches strings starting with numbers with all tests -k option cannot handle strings starting with a number that contain spaces Nov 18, 2017
@dnut dnut changed the title -k option cannot handle strings starting with a number that contain spaces -k cannot handle strings containing spaces that start with a number Nov 18, 2017
@RonnyPfannschmidt
Copy link
Member

closing as duplicate of #2896

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants