--- you can reply above this line ---

New issue 275: doctest does not consider usefixtures in pytest.ini
https://bitbucket.org/hpk42/pytest/issue/275/doctest-does-not-consider-usefixtures-in

Takafumi Arakaki:

Running `py.test` with the following files fail:

`pytest.ini`:
```
#!ini

[pytest]
addopts = --doctest-modules
usefixtures = myfixture
```

`conftest.py`:
```
#!python

import pytest


@pytest.fixture()
def myfixture(monkeypatch):
    monkeypatch.setenv('MYENV', 'value')
```


`test_env.py`:
```
#!python

"""
>>> os.environ['MYENV'] == 'value'
True
"""

import os


def test():
    assert os.environ['MYENV'] == 'value'
```

Normal test passes but doctest fails:
```
============================== test session starts 
===============================
platform linux2 -- Python 2.7.2 -- pytest-2.3.4
plugins: xdist, ipdb
collected 3 items 

conftest.py .
test_env.py F.

==================================== FAILURES 
====================================
___________________________________ [doctest] 
____________________________________
001 """
002 >>> os.environ['MYENV'] == 'value'
UNEXPECTED EXCEPTION: KeyError('MYENV',)
Traceback (most recent call last):

  File "/usr/lib/python2.7/doctest.py", line 1254, in __run
    compileflags, 1) in test.globs

  File "<doctest test_env[0]>", line 1, in <module>

  File "/.../lib/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)

KeyError: 'MYENV'

/.../test_env.py:2: UnexpectedException
======================= 1 failed, 2 passed in 0.02 seconds ====================
```



--

This is an issue notification from bitbucket.org. You are receiving
this either because you are the owner of the issue, or you are
following the issue.
_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
http://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to