From e13e23068cb8d653a02a434a159e8b0b7226ffd6 Mon Sep 17 00:00:00 2001 From: Jonathan Ringer Date: Tue, 11 Jan 2022 14:23:03 -0800 Subject: [PATCH] Make unittest optional for python3.5+ --- docs-requirements.txt | 2 +- test-requirements.txt | 2 +- tests/test_deprecation.py | 7 ++++++- tox.ini | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs-requirements.txt b/docs-requirements.txt index 9a23970..7e3e17c 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -1 +1 @@ -unittest2 +unittest2;python_version<'3.5' diff --git a/test-requirements.txt b/test-requirements.txt index e12bf36..8d3717d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,4 +2,4 @@ codecov>=2.0 coverage>=4.3 flake8>=3.2 packaging>=16.8 -unittest2>=1.1 +unittest2>=1.1;python_version<'3.5' diff --git a/tests/test_deprecation.py b/tests/test_deprecation.py index 0fd29b3..14e9510 100644 --- a/tests/test_deprecation.py +++ b/tests/test_deprecation.py @@ -12,7 +12,12 @@ # As we unfortunately support Python 2.7, it lacks TestCase.subTest which # is in 3.4+ or in unittest2 -import unittest2 +try: + import unittest2 +except ImportError: + import unittest + unittest2 = unittest + import warnings import deprecation diff --git a/tox.ini b/tox.ini index aa3da54..6941736 100644 --- a/tox.ini +++ b/tox.ini @@ -20,6 +20,6 @@ commands = coverage run -m unittest discover [testenv:docs] deps = Sphinx - unittest2 + unittest2;python_version<'3.5' changedir = docs commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . _build/html