summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy <jimmy@spalge.com>2022-03-26 15:56:45 +1300
committerJimmy <jimmy@spalge.com>2022-03-26 16:06:42 +1300
commit6341154aeb4f08272177dbc7a42ee7762a39b464 (patch)
treed1ad00ec08f6270749f13c0723da571174dd9d33
parenta546c5fcfc5b78269331cfe841eb88c30d657885 (diff)
downloadqutebrowser-6341154aeb4f08272177dbc7a42ee7762a39b464.tar.gz
qutebrowser-6341154aeb4f08272177dbc7a42ee7762a39b464.zip
Skip debucachestats test on python < 3.9
Refactor the magic tag creation thing to add python version checking support. Makes `_check_version()` support checking plain tuples to so that I don't have to copy the operator dict. Now most of the branches of the if/else are the same, meh.
-rw-r--r--tests/end2end/conftest.py33
-rw-r--r--tests/end2end/features/utilcmds.feature1
2 files changed, 25 insertions, 9 deletions
diff --git a/tests/end2end/conftest.py b/tests/end2end/conftest.py
index 1d9802049..14ac6f395 100644
--- a/tests/end2end/conftest.py
+++ b/tests/end2end/conftest.py
@@ -59,7 +59,7 @@ def pytest_unconfigure(config):
stats.dump_stats((pathlib.Path('prof') / 'combined.pstats'))
-def _check_hex_version(op_str, running_version, version):
+def _check_version(op_str, running_version, version_str, as_hex=False):
operators = {
'==': operator.eq,
'!=': operator.ne,
@@ -69,9 +69,12 @@ def _check_hex_version(op_str, running_version, version):
'<': operator.lt,
}
op = operators[op_str]
- major, minor, patch = [int(e) for e in version.split('.')]
- hex_version = (major << 16) | (minor << 8) | patch
- return op(running_version, hex_version)
+ major, minor, patch = [int(e) for e in version_str.split('.')]
+ if as_hex:
+ version = (major << 16) | (minor << 8) | patch
+ else:
+ version = (major, minor, patch)
+ return op(running_version, version)
def _get_version_tag(tag):
@@ -82,7 +85,7 @@ def _get_version_tag(tag):
casesinto an appropriate @pytest.mark.skip marker, and falls back to
"""
version_re = re.compile(r"""
- (?P<package>qt|pyqt|pyqtwebengine)
+ (?P<package>qt|pyqt|pyqtwebengine|python)
(?P<operator>==|>=|!=|<)
(?P<version>\d+\.\d+(\.\d+)?)
""", re.VERBOSE)
@@ -106,10 +109,11 @@ def _get_version_tag(tag):
return pytest.mark.skipif(do_skip[op], reason='Needs ' + tag)
elif package == 'pyqt':
return pytest.mark.skipif(
- not _check_hex_version(
+ not _check_version(
op_str=match.group('operator'),
running_version=PYQT_VERSION,
- version=version
+ version_str=version,
+ as_hex=True,
),
reason='Needs ' + tag,
)
@@ -121,10 +125,21 @@ def _get_version_tag(tag):
else:
running_version = PYQT_WEBENGINE_VERSION
return pytest.mark.skipif(
- not _check_hex_version(
+ not _check_version(
+ op_str=match.group('operator'),
+ running_version=running_version,
+ version_str=version,
+ as_hex=True,
+ ),
+ reason='Needs ' + tag,
+ )
+ elif package == 'python':
+ running_version = sys.version_info
+ return pytest.mark.skipif(
+ not _check_version(
op_str=match.group('operator'),
running_version=running_version,
- version=version
+ version_str=version,
),
reason='Needs ' + tag,
)
diff --git a/tests/end2end/features/utilcmds.feature b/tests/end2end/features/utilcmds.feature
index bb2b3e2fb..e8172ae20 100644
--- a/tests/end2end/features/utilcmds.feature
+++ b/tests/end2end/features/utilcmds.feature
@@ -93,6 +93,7 @@ Feature: Miscellaneous utility commands exposed to the user.
## :debug-cache-stats
+ @python>=3.9.0
Scenario: :debug-cache-stats
When I run :debug-cache-stats
Then "is_valid_prefix: CacheInfo(*)" should be logged