addresses issue #22
allow test functions to have no func_code --HG-- branch : 1.0.x
This commit is contained in:
		
							parent
							
								
									7602096f81
								
							
						
					
					
						commit
						f531a1d6c9
					
				| 
						 | 
					@ -6,6 +6,9 @@ Changes between 1.0.0b3 and 1.0.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* perform setup finalization before reporting failures
 | 
					* perform setup finalization before reporting failures
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* apply modified from Andreas Kloeckner to allow 
 | 
				
			||||||
 | 
					  test functions to have no func_code 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Changes between 1.0.0b1 and 1.0.0b3
 | 
					Changes between 1.0.0b1 and 1.0.0b3
 | 
				
			||||||
=============================================
 | 
					=============================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -133,7 +133,7 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector):
 | 
				
			||||||
            res = self._deprecated_join(name)
 | 
					            res = self._deprecated_join(name)
 | 
				
			||||||
            if res is not None:
 | 
					            if res is not None:
 | 
				
			||||||
                return res 
 | 
					                return res 
 | 
				
			||||||
            if obj.func_code.co_flags & 32: # generator function 
 | 
					            if is_generator(obj):
 | 
				
			||||||
                # XXX deprecation warning 
 | 
					                # XXX deprecation warning 
 | 
				
			||||||
                return self.Generator(name, parent=self)
 | 
					                return self.Generator(name, parent=self)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					@ -153,6 +153,12 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector):
 | 
				
			||||||
        return funcargs.FunctionCollector(name=name, 
 | 
					        return funcargs.FunctionCollector(name=name, 
 | 
				
			||||||
            parent=self, calls=metafunc._calls)
 | 
					            parent=self, calls=metafunc._calls)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def is_generator(func):
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        return (func.func_code.co_flags & 32) # generator function 
 | 
				
			||||||
 | 
					    except AttributeError: # c / builtin functions have no func_code
 | 
				
			||||||
 | 
					        return False 
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
class Module(py.test.collect.File, PyCollectorMixin):
 | 
					class Module(py.test.collect.File, PyCollectorMixin):
 | 
				
			||||||
    def _getobj(self):
 | 
					    def _getobj(self):
 | 
				
			||||||
        return self._memoizedcall('_obj', self._importtestmodule)
 | 
					        return self._memoizedcall('_obj', self._importtestmodule)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue