diff --git a/html5lib/tests/tokenizer.py b/html5lib/tests/tokenizer.py
index 8a4cf354..b49d2e6e 100644
--- a/html5lib/tests/tokenizer.py
+++ b/html5lib/tests/tokenizer.py
@@ -246,7 +246,7 @@ def runtest(self):
def repr_failure(self, excinfo):
traceback = excinfo.traceback
ntraceback = traceback.cut(path=__file__)
- pytest_ver = pytest.getattr("version_tuple", ())
+ pytest_ver = getattr(pytest, "version_tuple", ())
filter_args = (excinfo,) if pytest_ver >= (7, 4, 0) else ()
excinfo.traceback = ntraceback.filter(*filter_args)
diff --git a/html5lib/tests/tree_construction.py b/html5lib/tests/tree_construction.py
index 39ff1568..363b48c2 100644
--- a/html5lib/tests/tree_construction.py
+++ b/html5lib/tests/tree_construction.py
@@ -135,7 +135,7 @@ def runtest(self):
def repr_failure(self, excinfo):
traceback = excinfo.traceback
ntraceback = traceback.cut(path=__file__)
- pytest_ver = pytest.getattr("version_tuple", ())
+ pytest_ver = getattr(pytest, "version_tuple", ())
filter_args = (excinfo,) if pytest_ver >= (7, 4, 0) else ()
excinfo.traceback = ntraceback.filter(*filter_args)