New issue 768: doctests appear to run before session scope fixtures
https://bitbucket.org/pytest-dev/pytest/issue/768/doctests-appear-to-run-before-session

Jason R. Coombs:

I've created a session scoped fixture in ./conftest.py:

```
@pytest.fixture(autouse=True, scope='session')
def myfixture():
  raise ValueError()
```

Then, I create a module to be doctested:

```
def foo():
  """
  >>> assert True
  """
```

Then, I run pytest with `--doctest-modules`.

It completes one test on "mod.py" and it passes. Furthermore, if anything in 
the session scope is required by the doctest, it won't yet be setup. It seems 
that doctests are run outside of the test session.

I understand that session scope fixtures [are meant to serve as test setup and 
teardown](http://stackoverflow.com/a/12600154/70170). However, they seem not to 
be available for doctests.

Is there any way to set up the context for doctests? I'd like to incorporate 
another fixture from a plugin during setup as well.


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

Reply via email to