2016-05-25 07:04:02 +00:00
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
2019-01-17 23:03:56 +00:00
|
|
|
_VERSION_MARKER = re.compile('_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:
|
|
|
|
version_match = (major_version, minor_version) == sys.version_info[:2]
|
|
|
|
else:
|
|
|
|
version_match = major_version == sys.version_info[0]
|
|
|
|
|
|
|
|
return not version_match # because this is an _ignore_ (not an include)
|