Skip to content

Commit

Permalink
Use fixture for tmpdir
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Jul 29, 2024
1 parent 51cd2ff commit 8570afd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion audinterface/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from doctest import ELLIPSIS
from doctest import NORMALIZE_WHITESPACE

from sybil import Sybil
from sybil.parsers.rest import DocTestParser


pytest_collect_file = Sybil(
parsers=[DocTestParser(optionflags=NORMALIZE_WHITESPACE)],
parsers=[DocTestParser(optionflags=NORMALIZE_WHITESPACE + ELLIPSIS)],
patterns=["*.py"],
).pytest()
17 changes: 16 additions & 1 deletion docs/conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
from doctest import ELLIPSIS
from doctest import NORMALIZE_WHITESPACE
import os

import pytest
from sybil import Sybil
from sybil.parsers.rest import DocTestParser
from sybil.parsers.rest import PythonCodeBlockParser


@pytest.fixture(scope="module")
def execute_in_tmpdir(tmpdir_factory):
path = tmpdir_factory.mktemp("doctest")
cwd = os.getcwd()
try:
os.chdir(path)
yield path
finally:
os.chdir(cwd)


pytest_collect_file = Sybil(
parsers=[
DocTestParser(optionflags=NORMALIZE_WHITESPACE),
DocTestParser(optionflags=NORMALIZE_WHITESPACE + ELLIPSIS),
PythonCodeBlockParser(),
],
patterns=["*.rst"],
fixtures=["execute_in_tmpdir"],
).pytest()

0 comments on commit 8570afd

Please sign in to comment.