From 5ec6e5e614679ee938545704fad958a3491c678b Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 17 Oct 2023 18:07:52 -0400 Subject: [PATCH 1/2] tests: drop dependency on external mock module for newer python Starting python 3.3, this is in the stdlib. Fixes #541 --- html5lib/tests/test_meta.py | 5 ++++- requirements-test.txt | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/html5lib/tests/test_meta.py b/html5lib/tests/test_meta.py index dd02dd7f..400fb802 100644 --- a/html5lib/tests/test_meta.py +++ b/html5lib/tests/test_meta.py @@ -1,7 +1,10 @@ from __future__ import absolute_import, division, unicode_literals import six -from mock import Mock +try: + from unittest.mock import Mock +except: + from mock import Mock from . import support diff --git a/requirements-test.txt b/requirements-test.txt index 27866e59..9626ca1d 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -6,5 +6,4 @@ pytest>=4.6.10,<5 ; python_version < '3' pytest>=5.4.2,<7 ; python_version >= '3' coverage>=5.1,<6 pytest-expect>=1.1.0,<2 -mock>=3.0.5,<4 ; python_version < '3.6' -mock>=4.0.2,<5 ; python_version >= '3.6' +mock>=3.0.5,<4 ; python_version < '3.3' From 462e6b3b91d0b02f15e79436b85bd46d18bd3592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Wed, 10 Jan 2024 16:39:13 +0100 Subject: [PATCH 2/2] Use `ImportError` instead of bare `except:` --- html5lib/tests/test_meta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html5lib/tests/test_meta.py b/html5lib/tests/test_meta.py index 400fb802..e02268aa 100644 --- a/html5lib/tests/test_meta.py +++ b/html5lib/tests/test_meta.py @@ -3,7 +3,7 @@ import six try: from unittest.mock import Mock -except: +except ImportError: from mock import Mock from . import support