[py-svn] r7161 - py/dist/py/path/extpy
hpk at codespeak.net
hpk at codespeak.net
Sun Oct 31 17:31:16 CET 2004
Author: hpk
Date: Sun Oct 31 17:31:15 2004
New Revision: 7161
Modified:
py/dist/py/path/extpy/extpy.py
py/dist/py/path/extpy/inc_test_extpy.py
py/dist/py/path/extpy/test_extpy.py
Log:
added a "genfunc" checker that looks if a
path points to a generator function (i.e.
a function that will produce a generator when called)
Modified: py/dist/py/path/extpy/extpy.py
==============================================================================
--- py/dist/py/path/extpy/extpy.py (original)
+++ py/dist/py/path/extpy/extpy.py Sun Oct 31 17:31:15 2004
@@ -231,3 +231,9 @@
def file(self):
return not self.dir()
+
+ def genfunc(self):
+ try:
+ return self._obj().func_code.co_flags & 32
+ except AttributeError:
+ return False
Modified: py/dist/py/path/extpy/inc_test_extpy.py
==============================================================================
--- py/dist/py/path/extpy/inc_test_extpy.py (original)
+++ py/dist/py/path/extpy/inc_test_extpy.py Sun Oct 31 17:31:15 2004
@@ -1,9 +1,13 @@
+from __future__ import generators
class A:
x1 = 42
def func(self):
pass
+ def genfunc(self):
+ yield 2
+
class B:
x2 = 23
Modified: py/dist/py/path/extpy/test_extpy.py
==============================================================================
--- py/dist/py/path/extpy/test_extpy.py (original)
+++ py/dist/py/path/extpy/test_extpy.py Sun Oct 31 17:31:15 2004
@@ -119,6 +119,14 @@
p = self.root.join('A.x1')
assert p.check(func=0)
+ def test_generatorfunction(self):
+ p = self.root.join('A.genfunc')
+ assert p.check(genfunc=1)
+ p = self.root.join('A.func')
+ assert p.check(genfunc=0)
+ p = self.root.join('A')
+ assert p.check(genfunc=0)
+
def test_hashing_equality(self):
x = self.root
y = self.root.new()
More information about the pytest-commit
mailing list