Skip to content

Commit 60dfa85

Browse files
committed
Add Python < 3.6 support to tests
The package should work with Python 2.7 or any version of Python, since it's a data-only package, but some of the testing infrastructure no longer supports Python 2.7. For the moment, we'll make sure it works with 2.7, though we will likely not continue to test on 2.7 indefinitely.
1 parent 0ce8a28 commit 60dfa85

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tests/test_contents.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1+
import sys
2+
3+
import pytest
4+
15
try:
26
from importlib import resources
37
except ImportError:
48
import importlib_resources as resources
59

6-
import pytest
10+
11+
if sys.version_info < (3, 6):
12+
# pytest-subtests does not support Python < 3.6, but having the tests
13+
# separated into clean subtests is nice but not required, so we will create
14+
# a stub that does nothing but at least doesn't fail for lack of a fixture.
15+
import contextlib
16+
17+
class _SubTestStub:
18+
@contextlib.contextmanager
19+
def test(self, **kwargs):
20+
yield
21+
22+
_sub_test_stub = _SubTestStub()
23+
24+
@pytest.fixture
25+
def subtests():
26+
yield _sub_test_stub
727

828

929
def get_magic(zone_name):

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ skip_missing_interpreters = true
77
description = Test that the tzdata contents are accessible
88
deps =
99
pytest
10-
pytest-subtests
10+
pytest-subtests; python_version>='3.6'
1111
importlib_resources; python_version<'3.7'
1212
commands =
1313
pytest {toxinidir} {posargs}

0 commit comments

Comments
 (0)