Ronald Oussoren avatar Ronald Oussoren committed 9869efe

Use unittest2 for python 2.6 test support

Comments (0)

Files changed (12)

macholib_tests/test_MachO.py

 from macholib import MachO
 
-import unittest
-
-try:
-    expectedFailure = unittest.expectedFailure
-except AttributeError:
-    from macholib_tests.test_MachOGraph import expectedFailure
-
+import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 class TestMachO (unittest.TestCase):
-    @expectedFailure
+    @unittest.expectedFailure
     def test_missing(self):
         self.fail("tests are missing")
 

macholib_tests/test_MachOGraph.py

 from macholib import MachOGraph
 
-import unittest
-
-try:
-    expectedFailure = unittest.expectedFailure
-except AttributeError:
-    def expectedFailure(function):
-        def wrapper(self):
-            try:
-                function(self)
-            except AssertionError:
-                print ("ignore expected failure")
-        return wrapper
-
+import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 class TestMachOGraph (unittest.TestCase):
-    @expectedFailure
+    @unittest.expectedFailure
     def test_missing(self):
         self.fail("tests are missing")
 

macholib_tests/test_MachOStandalone.py

 from macholib import MachOStandalone
 
-import unittest
-
-try:
-    expectedFailure = unittest.expectedFailure
-except AttributeError:
-    from macholib_tests.test_MachOGraph import expectedFailure
-
+import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 class TestMachOStandalone (unittest.TestCase):
-    @expectedFailure
+    @unittest.expectedFailure
     def test_missing(self):
         self.fail("tests are missing")
 

macholib_tests/test_SymbolTable.py

 from macholib import SymbolTable
 
-import unittest
-
-try:
-    expectedFailure = unittest.expectedFailure
-except AttributeError:
-    from macholib_tests.test_MachOGraph import expectedFailure
-
+import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 class TestSymbolTable (unittest.TestCase):
-    @expectedFailure
+    @unittest.expectedFailure
     def test_missing(self):
         self.fail("tests are missing")
 

macholib_tests/test_command_line.py

 from macholib import _cmdline
 from macholib import util
 
-import unittest
 import sys
 import shutil
 import os
+
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
+
 try:
     from StringIO import StringIO
 except ImportError:

macholib_tests/test_dyld.py

 from macholib import dyld
 
-import unittest
 import sys
 import os
 import functools
 
-try:
-    expectedFailure = unittest.expectedFailure
-except AttributeError:
-    from macholib_tests.test_MachOGraph import expectedFailure
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 class DyldPatcher (object):
     def __init__(self):

macholib_tests/test_dylib.py

-import unittest
 from macholib import dylib
 
+import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
+
 def d(location=None, name=None, shortname=None, version=None, suffix=None):
     return dict(
         location=location,

macholib_tests/test_framework.py

 from macholib import framework
 
-import unittest
-
-try:
-    expectedFailure = unittest.expectedFailure
-except AttributeError:
-    from macholib_tests.test_MachOGraph import expectedFailure
+import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 
 class TestFramework (unittest.TestCase):

macholib_tests/test_itergraphreport.py

 from macholib import itergraphreport
 
-import unittest
-
-try:
-    expectedFailure = unittest.expectedFailure
-except AttributeError:
-    from macholib_tests.test_MachOGraph import expectedFailure
+import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 class TestIterGraphReport (unittest.TestCase):
-    @expectedFailure
+    @unittest.expectedFailure
     def test_missing(self):
         self.fail("tests are missing")
 

macholib_tests/test_mach_o.py

 from macholib import mach_o
 
-import unittest
-
-try:
-    expectedFailure = unittest.expectedFailure
-except AttributeError:
-    from macholib_tests.test_MachOGraph import expectedFailure
+import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 
 class TestMachO (unittest.TestCase):

macholib_tests/test_ptypes.py

 
 import unittest
 import sys
+if sys.version_info[:2] <= (2,6):
+    import unittest2 as unittest
+else:
+    import unittest
 
 try:
     from io import BytesIO
 
         metadata['entry_points']['console_scripts'] = v.splitlines()
 
-
-
     options = {}
     _opt_value(cfg, options, 'x-setup-stub', 'distribute-version')
 
+    if sys.version_info[:2] <= (2,6):
+        try:
+            metadata['tests_require'] += ", unittest2"
+        except KeyError:
+            metadata['tests_require'] = "unittest2"
+
     return metadata, options
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.