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 35 36 37 38 39 40 41 42 43 44 45 46 47
|
import sys
from pathlib import Path
try:
from pytest import File as FileCollector
except ImportError:
from pytest.collect import File as FileCollector
version = tuple(sys.version_info[:2])
class DummyCollector(FileCollector):
def collect(self):
return []
def construct_dummy(path: Path, parent):
if hasattr(DummyCollector, "from_parent"):
item = DummyCollector.from_parent(parent, path=path)
return item
else:
return DummyCollector(path, parent=parent)
def pytest_pycollect_makemodule(module_path: Path, parent):
name = module_path.name
if '_py33' in name and version < (3, 3):
return construct_dummy(path, parent)
if '_py34' in name and version < (3, 4):
return construct_dummy(path, parent)
if '_py35' in name and version < (3, 5):
return construct_dummy(path, parent)
if '_py36' in name and version < (3, 6):
return construct_dummy(path, parent)
if '_py37' in name and version < (3, 7):
return construct_dummy(path, parent)
if '_py38' in name and version < (3, 8):
return construct_dummy(path, parent)
if '_py39' in name and version < (3, 9):
return construct_dummy(path, parent)
if '_py310' in name and version < (3, 10):
return construct_dummy(path, parent)
if '_py311' in name and version < (3, 11):
return construct_dummy(path, parent)
if '_py312' in name and version < (3, 12):
return construct_dummy(path, parent)
if '_py3' in name and version < (3, 0):
return construct_dummy(path, parent)
if '_py2' in name and version >= (3, 0):
return construct_dummy(path, parent)
|