Commits

Arve Knudsen committed 4941181 Merge

Merge with default

  • Participants
  • Parent commits aaa7886, cc62de1
  • Branches arve.knudsen

Comments (0)

Files changed (4)

 \.noseids
+.*\.egg-info$
 dist
 \..*\.sw.
 .*\~
-.*\.egg-info
 .+\.py[co]
+Jason Pellerin
+Augie Fackler

File nose2/plugins/loader.py

 import inspect
 from unittest2.plugins import moduleloading as ml
-
+from nose2 import util
 
 def unpack(_self, generator):
     for index, func_args in enumerate(generator):
         return super(Functions, self).createTests(obj, testIndex)
 
     def isGenerator(self, obj):
-        return (inspect.isgeneratorfunction(obj) or
+        return (util.isgeneratorfunction(obj) or
                 super(Functions, self).isGenerator(obj))
 
 
     unpack = unpack
 
     def isGenerator(self, obj):
-        return (inspect.isgeneratorfunction(obj) or
+        return (util.isgeneratorfunction(obj) or
                 super(Generators, self).isGenerator(obj))
-
-

File nose2/util.py

+try:
+    from compiler.consts import CO_GENERATOR
+except ImportError:
+    # IronPython doesn't have a complier module
+    CO_GENERATOR=0x20
+
+try:
+    from inspect import isgeneratorfunction # new in 2.6
+except ImportError:
+    import inspect
+    # backported from Python 2.6
+    def isgeneratorfunction(func):
+        return bool((inspect.isfunction(func) or inspect.ismethod(func)) and
+                    func.func_code.co_flags & CO_GENERATOR)
+
 def ln(label, char='-', width=70):
     """Draw a divider, with label in the middle.