From d5512fd6ff98197a67623bd35f255764b5a98840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 25 May 2016 13:39:02 +0200 Subject: [PATCH] Use unittest2 if available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The module backports features to Python 2.6 and 2.7. If it is available, the tests will use it. If it is not available, it will fall back to regular unittest. On Python 2.7, the tests pass anyway. On Python 2.6, there are failures with Python 2.6. Signed-off-by: Lubomír Sedlář --- tests/helpers.py | 5 ++++- tests/test_buildinstall.py | 5 ++++- tests/test_checks.py | 5 ++++- tests/test_compose.py | 5 ++++- tests/test_createiso_phase.py | 5 ++++- tests/test_createrepo_wrapper.py | 5 ++++- tests/test_createrepophase.py | 5 ++++- tests/test_imagebuildphase.py | 5 ++++- tests/test_imagechecksumphase.py | 6 ++++-- tests/test_koji_wrapper.py | 5 ++++- tests/test_lorax_wrapper.py | 5 ++++- tests/test_pkgset_pkgsets.py | 5 ++++- tests/test_scm.py | 5 ++++- tests/test_test_phase.py | 5 ++++- tests/test_util.py | 5 ++++- 15 files changed, 60 insertions(+), 16 deletions(-) diff --git a/tests/helpers.py b/tests/helpers.py index d0049af4..9a6b04bd 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -2,7 +2,10 @@ import mock import os -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import tempfile import shutil import errno diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 48d5bbf6..b4c1653d 100755 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import mock import os diff --git a/tests/test_checks.py b/tests/test_checks.py index 0e2a9e2b..d39dbf86 100755 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- import mock -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import os import sys import StringIO diff --git a/tests/test_compose.py b/tests/test_compose.py index c40c9d1d..a590929e 100755 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- import mock -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import os import sys import tempfile diff --git a/tests/test_createiso_phase.py b/tests/test_createiso_phase.py index 304aea8a..7861fe0a 100755 --- a/tests/test_createiso_phase.py +++ b/tests/test_createiso_phase.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import mock import os diff --git a/tests/test_createrepo_wrapper.py b/tests/test_createrepo_wrapper.py index 708720c5..29dadfb0 100755 --- a/tests/test_createrepo_wrapper.py +++ b/tests/test_createrepo_wrapper.py @@ -1,7 +1,10 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import os import sys diff --git a/tests/test_createrepophase.py b/tests/test_createrepophase.py index a1084d91..43593bad 100755 --- a/tests/test_createrepophase.py +++ b/tests/test_createrepophase.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import mock import os diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py index 40e383f6..f87fe6a0 100755 --- a/tests/test_imagebuildphase.py +++ b/tests/test_imagebuildphase.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import mock import os diff --git a/tests/test_imagechecksumphase.py b/tests/test_imagechecksumphase.py index 6e235950..30d1f856 100755 --- a/tests/test_imagechecksumphase.py +++ b/tests/test_imagechecksumphase.py @@ -1,8 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import mock import os diff --git a/tests/test_koji_wrapper.py b/tests/test_koji_wrapper.py index 1a043824..72ec13ff 100755 --- a/tests/test_koji_wrapper.py +++ b/tests/test_koji_wrapper.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- import mock -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import tempfile import os diff --git a/tests/test_lorax_wrapper.py b/tests/test_lorax_wrapper.py index 64567da7..0dfd6cdf 100755 --- a/tests/test_lorax_wrapper.py +++ b/tests/test_lorax_wrapper.py @@ -1,7 +1,10 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import os import sys diff --git a/tests/test_pkgset_pkgsets.py b/tests/test_pkgset_pkgsets.py index 72e2bdd4..8c88b267 100755 --- a/tests/test_pkgset_pkgsets.py +++ b/tests/test_pkgset_pkgsets.py @@ -4,7 +4,10 @@ import mock import os import sys -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import json import tempfile diff --git a/tests/test_scm.py b/tests/test_scm.py index 624381a5..d713669b 100755 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- import mock -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import shutil import tempfile diff --git a/tests/test_test_phase.py b/tests/test_test_phase.py index e21dd238..ef8e40fc 100755 --- a/tests/test_test_phase.py +++ b/tests/test_test_phase.py @@ -2,7 +2,10 @@ # -*- coding: utf-8 -*- -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import os import sys diff --git a/tests/test_util.py b/tests/test_util.py index 6678a274..1c37915e 100755 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -4,7 +4,10 @@ import mock import os import sys -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import tempfile import shutil