File: conftest.py

package info (click to toggle)
python-parsel 1.6.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 332 kB
  • sloc: python: 1,467; makefile: 213; sh: 8
file content (32 lines) | stat: -rw-r--r-- 873 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
import os
from doctest import ELLIPSIS, NORMALIZE_WHITESPACE
from sys import version_info

from sybil import Sybil
from sybil.parsers.codeblock import CodeBlockParser
from sybil.parsers.doctest import DocTestParser
from sybil.parsers.skip import skip

from parsel import Selector


def load_selector(filename, **kwargs):
    input_path = os.path.join(os.path.dirname(__file__), '_static', filename)
    with open(input_path) as input_file:
        return Selector(text=input_file.read(), **kwargs)


def setup(namespace):
    namespace['load_selector'] = load_selector


if version_info >= (3,):
    pytest_collect_file = Sybil(
        parsers=[
            DocTestParser(optionflags=ELLIPSIS | NORMALIZE_WHITESPACE),
            CodeBlockParser(future_imports=['print_function']),
            skip,
        ],
        pattern='*.rst',
        setup=setup,
    ).pytest()