Use unittest2 if available

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-05-25 13:39:02 +02:00
parent b634a18a7f
commit d5512fd6ff
15 changed files with 60 additions and 16 deletions

View File

@ -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

View File

@ -2,7 +2,10 @@
# -*- coding: utf-8 -*-
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
import mock
import os

View File

@ -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

View File

@ -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

View File

@ -2,7 +2,10 @@
# -*- coding: utf-8 -*-
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
import mock
import os

View File

@ -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

View File

@ -2,7 +2,10 @@
# -*- coding: utf-8 -*-
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
import mock
import os

View File

@ -2,7 +2,10 @@
# -*- coding: utf-8 -*-
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
import mock
import os

View File

@ -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

View File

@ -2,7 +2,10 @@
# -*- coding: utf-8 -*-
import mock
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
import tempfile
import os

View File

@ -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

View File

@ -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

View File

@ -2,7 +2,10 @@
# -*- coding: utf-8 -*-
import mock
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
import shutil
import tempfile

View File

@ -2,7 +2,10 @@
# -*- coding: utf-8 -*-
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
import os
import sys

View File

@ -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