New issue 770: Exception while using getfixture call in doctests for pytest > 
2.4.2 with module scoped fixture
https://bitbucket.org/pytest-dev/pytest/issues/770/exception-while-using-getfixture-call-in

Karthik Borkar:

In** pytest > 2.4.2**

my conftest.py file


```
#!python

@pytest.fixture(scope="module")
def config(request):
    ....
```

my doc file

```
#!doc

.. testsetup:: [*]

    >>> from lib.ShellExecutor import *
    >>> shell=ShellExecutor(getfixture('config'))
...
```

When i run the doc test, i get this error

```
#!error

001 .. testsetup:: [*]
002 
003     >>> from lib.ShellExecutor import *
004     >>> shell = ShellExecutor(getfixture('config'))
UNEXPECTED EXCEPTION: AssertionError(u'assert None',)
Traceback (most recent call last):

  File "/usr/lib64/python2.6/doctest.py", line 1253, in __run
    compileflags, 1) in test.globs

  File "<doctest view-command-history.rst[1]>", line 1, in <module>

  File 
"/home/dev/Qubole/docs/doc_new/lib/python2.6/site-packages/pytest-2.7.0-py2.6.egg/_pytest/python.py",
 line 1383, in getfuncargvalue
    return self._get_active_fixturedef(argname).cached_result[0]

  File 
"/home/dev/Qubole/docs/doc_new/lib/python2.6/site-packages/pytest-2.7.0-py2.6.egg/_pytest/python.py",
 line 1399, in _get_active_fixturedef
    result = self._getfuncargvalue(fixturedef)

  File 
"/home/dev/Qubole/docs/doc_new/lib/python2.6/site-packages/pytest-2.7.0-py2.6.egg/_pytest/python.py",
 line 1458, in _getfuncargvalue
    subrequest.node)

  File 
"/home/dev/Qubole/docs/doc_new/lib/python2.6/site-packages/pytest-2.7.0-py2.6.egg/_pytest/python.py",
 line 1233, in node
    return self._getscopeitem(self.scope)

  File 
"/home/dev/Qubole/docs/doc_new/lib/python2.6/site-packages/pytest-2.7.0-py2.6.egg/_pytest/python.py",
 line 1480, in _getscopeitem
    assert node

AssertionError: assert None

```
This works fine with **pytest == 2.4.2** as i was using this for sometime now. 
Error only in **pytest >= 2.4.2**

and also in **pytest > 2.4.2**  i used function scoped fixture, it worked


```
#!python

@pytest.fixture(scope="function")
def config(request):
```

There is no error, doctest working fine




_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to