Skip to content

Running a specific test parameter that has '-' causes syntax error #557

@pytestbot

Description

@pytestbot

Originally reported by: BitBucket: andii1701, GitHub: andii1701


Hello I noticed when running a test with a specific parameter causes an syntax error.

For example:

#!python

$ py.test -v -s -k test_eval[3+5-8]
========================================================================== test session starts ==========================================================================
platform linux -- Python 3.3.2 -- py-1.4.22 -- pytest-2.6.0 -- /home/ajones/Envs/1800respect/bin/python3.3
plugins: xdist, cov, django
collected 5 items 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/main.py", line 83, in wrap_session
INTERNALERROR>     doit(config, session)
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/main.py", line 120, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/core.py", line 412, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/core.py", line 423, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/core.py", line 314, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/main.py", line 124, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/main.py", line 546, in perform_collect
INTERNALERROR>     config=self.config, items=items)
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/core.py", line 412, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/core.py", line 423, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/core.py", line 314, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/mark.py", line 67, in pytest_collection_modifyitems
INTERNALERROR>     if keywordexpr and not matchkeyword(colitem, keywordexpr):
INTERNALERROR>   File "/home/ajones/Envs/1800respect/lib/python3.3/site-packages/_pytest/mark.py", line 150, in matchkeyword
INTERNALERROR>     return eval(keywordexpr, {}, mapping)
INTERNALERROR>   File "<string>", line 1
INTERNALERROR>     test_eval[3+5not 8]
INTERNALERROR>                      ^
INTERNALERROR> SyntaxError: invalid syntax

The problem is the '-' in the square bracket is getting converted to 'not '. Pull request with a fix is on its way.


Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions