2016-05-25 07:04:02 +00:00
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
2020-01-31 18:52:52 +00:00
|
|
|
_VERSION_MARKER = re.compile(r'_py(?P<major_version>\d)(?P<minor_version>\d)?')
|
2016-05-25 07:04:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2019-01-17 23:03:56 +00:00
|
|
|
if not match:
|
|
|
|
return False
|
|
|
|
major_version = match.group('major_version')
|
|
|
|
minor_version = match.group('minor_version')
|
|
|
|
|
|
|
|
if minor_version:
|
2019-01-17 23:10:34 +00:00
|
|
|
version_match = (int(major_version), int(minor_version)) == sys.version_info[:2]
|
2019-01-17 23:03:56 +00:00
|
|
|
else:
|
2019-01-17 23:10:34 +00:00
|
|
|
version_match = int(major_version) == sys.version_info[0]
|
2019-01-17 23:03:56 +00:00
|
|
|
|
|
|
|
return not version_match # because this is an _ignore_ (not an include)
|