File: conftest.py

package info (click to toggle)
python-testfixtures 8.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,064 kB
  • sloc: python: 10,208; makefile: 76; sh: 9
file content (34 lines) | stat: -rw-r--r-- 929 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from doctest import REPORT_NDIFF, ELLIPSIS

from sybil import Sybil
from sybil.parsers.doctest import DocTestParser
from sybil.parsers.codeblock import PythonCodeBlockParser
from sybil.parsers.capture import parse_captures
from sybil.parsers.skip import skip

from testfixtures import TempDirectory
from testfixtures.sybil import FileParser


def sybil_setup(namespace):
    # _tempdir is in case it's overwritten by a test.
    namespace['tempdir'] = namespace['_tempdir'] = TempDirectory()


def sybil_teardown(namespace):
    namespace['_tempdir'].cleanup()


pytest_collect_file = Sybil(
    parsers=[
        DocTestParser(optionflags=REPORT_NDIFF|ELLIPSIS),
        PythonCodeBlockParser(),
        parse_captures,
        FileParser('tempdir'),
        skip,
    ],
    patterns=['*.txt', '*.py'],
    setup=sybil_setup, teardown=sybil_teardown,
    fixtures=['tmp_path'],
    exclude='testfixtures/tests/*.py'
).pytest()