Skip to content

Instantly share code, notes, and snippets.

@smugmug-api-docs
Last active August 29, 2015 14:14
Show Gist options
  • Save smugmug-api-docs/321b9586e27ad938ebd5 to your computer and use it in GitHub Desktop.
Save smugmug-api-docs/321b9586e27ad938ebd5 to your computer and use it in GitHub Desktop.
py.test -k problem
============================= test session starts ==============================
platform darwin -- Python 2.7.6 -- py-1.4.20 -- pytest-2.5.2
plugins: xdist
collected 9 items
test_example.py ..F......
=================================== FAILURES ===================================
__________________________ test_multiple_params[4-3] ___________________________
foo = 3, bar = 4
@pytest.mark.parametrize('foo', [1, 2, 3])
@pytest.mark.parametrize('bar', [4, 5, 6])
def test_multiple_params(foo, bar):
> assert foo + 1 != bar
E assert (3 + 1) != 4
test_example.py:6: AssertionError
====================== 1 failed, 8 passed in 0.02 seconds ======================
============================= test session starts ==============================
platform darwin -- Python 2.7.6 -- py-1.4.20 -- pytest-2.5.2
plugins: xdist
collected 9 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py", line 81, in wrap_session
INTERNALERROR> doit(config, session)
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py", line 117, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py", line 377, in __call__
INTERNALERROR> return self._docall(methods, kwargs)
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py", line 388, in _docall
INTERNALERROR> res = mc.execute()
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py", line 289, in execute
INTERNALERROR> res = method(**kwargs)
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py", line 121, in pytest_collection
INTERNALERROR> return session.perform_collect()
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py", line 520, in perform_collect
INTERNALERROR> config=self.config, items=items)
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py", line 377, in __call__
INTERNALERROR> return self._docall(methods, kwargs)
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py", line 388, in _docall
INTERNALERROR> res = mc.execute()
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/core.py", line 289, in execute
INTERNALERROR> res = method(**kwargs)
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/mark.py", line 67, in pytest_collection_modifyitems
INTERNALERROR> if keywordexpr and not matchkeyword(colitem, keywordexpr):
INTERNALERROR> File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/mark.py", line 149, in matchkeyword
INTERNALERROR> return eval(keywordexpr, {}, mapping)
INTERNALERROR> File "<string>", line 1
INTERNALERROR> test_multiple_params[3not 4]
INTERNALERROR> ^
INTERNALERROR> SyntaxError: invalid syntax
=============================== in 0.01 seconds ===============================
py.test test_example.py
# We see that one case fails, test_multiple_params[3-4]. Let's try to re-run that case:
py.test test_example.py -k 'test_multiple_params[3-4]'
# The -k expression interpreter sees '-' as an operator
import pytest
@pytest.mark.parametrize('foo', [1, 2, 3])
@pytest.mark.parametrize('bar', [4, 5, 6])
def test_multiple_params(foo, bar):
assert foo + 1 != bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment