[py-dev] error in teardown wrongly reported as error in setup

Ralf Schmitt ralf at systemexit.de
Fri Jun 10 17:09:25 CEST 2011


I have a directory with two test files with the following content:

,----[ test_1.py ]
| #! /usr/bin/env py.test
| 
| def pytest_funcarg__hello(request):
|     def setup():
|         return "hello world"
| 
|     def teardown(idx):
|         raise RuntimeError("fail")
| 
|     return request.cached_setup(
|         setup=setup,
|         teardown=teardown,
|         scope="module")
| 
| 
| def test_val(hello):
|     assert hello == "hello world"
`----

,----[ test_2.py ]
| def test_foo():
|     pass
`----

py.test reports an error for test_foo:

,----
| ========================== test session starts ==========================
| platform linux2 -- Python 2.7.2 -- pytest-2.0.3
| collected 2 items 
| 
| test_1.py .
| test_2.py E
| 
| ================================ ERRORS =================================
| ______________________ ERROR at setup of test_foo _______________________
| 
| idx = 'hello world'
| 
|     def teardown(idx):
| >       raise RuntimeError("fail")
| E       RuntimeError: fail
| 
| test_1.py:8: RuntimeError
| =================== 1 passed, 1 error in 0.10 seconds ===================
`----

Cheers,
- Ralf



More information about the Pytest-dev mailing list