File: conftest.py

package info (click to toggle)
python-boltons 25.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,236 kB
  • sloc: python: 12,133; makefile: 159; sh: 7
file content (26 lines) | stat: -rw-r--r-- 782 bytes parent folder | download | duplicates (2)
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
import sys
import re


_VERSION_MARKER = re.compile(r'_py(?P<major_version>\d)(?P<minor_version>\d)?')


def pytest_ignore_collect(path, config):
    """
    Ignore tests that end with _pyX, where X does not equal this
    interpreter's major version.
    """
    filename = path.basename
    modulename = filename.split('.', 1)[0]
    match = _VERSION_MARKER.search(modulename)
    if not match:
        return False
    major_version = match.group('major_version')
    minor_version = match.group('minor_version')

    if minor_version:
        version_match = (int(major_version), int(minor_version)) == sys.version_info[:2]
    else:
        version_match = int(major_version) == sys.version_info[0]

    return not version_match  # because this is an _ignore_ (not an include)