File: conftest.py

package info (click to toggle)
python-asdf 2.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 3,248 kB
  • sloc: python: 13,104; makefile: 125
file content (20 lines) | stat: -rw-r--r-- 674 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pytest

@pytest.fixture(autouse=True)
def _docdir(request):
    """
    Make sure that doctests run in a temporary directory so that any files that
    are created as part of the test get removed automatically.
    """
    # Trigger ONLY for doctestplus.
    try:
        doctest_plugin = request.config.pluginmanager.getplugin("doctestplus")
        if isinstance(request.node.parent, doctest_plugin._doctest_textfile_item_cls):
            tmpdir = request.getfixturevalue('tmpdir')
            with tmpdir.as_cwd():
                yield
        else:
            yield
    # Handle case where doctestplus is not available
    except AttributeError:
        yield