Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r50374:0d499a1ce192
Date: 2011-12-11 12:24 +0100
http://bitbucket.org/pypy/pypy/changeset/0d499a1ce192/

Log:    Fix. The testing framework was happily accepting app-level methods
        that are generators, and then running the yielded functions at
        interp-level :-( Add a hack to conftest.py to prevent that, and
        rewrite the test in a non-generator style. Now it fails, good.

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -496,6 +496,17 @@
     def setup(self):
         super(AppClassCollector, self).setup()
         cls = self.obj
+        #
+        # <hack>
+        for name in dir(cls):
+            if name.startswith('test_'):
+                func = getattr(cls, name, None)
+                code = getattr(func, 'func_code', None)
+                if code and code.co_flags & 32:
+                    raise AssertionError("unsupported: %r is a generator "
+                                         "app-level test method" % (name,))
+        # </hack>
+        #
         space = cls.space
         clsname = cls.__name__
         if self.config.option.runappdirect:
diff --git a/pypy/module/_hashlib/test/test_hashlib.py 
b/pypy/module/_hashlib/test/test_hashlib.py
--- a/pypy/module/_hashlib/test/test_hashlib.py
+++ b/pypy/module/_hashlib/test/test_hashlib.py
@@ -80,28 +80,27 @@
         _hashlib.openssl_sha1(b).digest()
 
     def test_extra_algorithms(self):
-        import _hashlib
-        test_string = "Nobody inspects the spammish repetition"
         expected_results = {
             "md5": "bb649c83dd1ea5c9d9dec9a18df0ffe9",
             "md4": "c275b8454684ea416b93d7a418b43176",
             "mdc2": None,   # XXX find the correct expected value
             "sha": "e2b0a8609b47c58e5d984c9ccfe69f9b654b032b",
             "ripemd160": "cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc",
-            "whirlpool": "1a22b79fe5afda02c63a25927193ed01dc718b74"
-                         "026e597608ce431f9c3d2c9e74a7350b7fbb7c5d"
-                         "4effe5d7a31879b8b7a10fd2f544c4ca268ecc6793923583",
+            "whirlpool": ("1a22b79fe5afda02c63a25927193ed01dc718b74"
+                          "026e597608ce431f9c3d2c9e74a7350b7fbb7c5d"
+                          "4effe5d7a31879b8b7a10fd2f544c4ca268ecc6793923583"),
             }
-        def extracheck(hash_name, expected):
+        import _hashlib
+        test_string = "Nobody inspects the spammish repetition"
+        for hash_name, expected in sorted(expected_results.items()):
             try:
                 m = _hashlib.new(hash_name)
             except ValueError, e:
-                skip('%s: %s' % (hash_name, e))
+                print 'skipped %s: %s' % (hash_name, e)
+                continue
             m.update(test_string)
             got = m.hexdigest()
             assert got and type(got) is str and len(got) % 2 == 0
             got.decode('hex')
             if expected is not None:
                 assert got == expected
-        for hash_name, expected in sorted(expected_results.items()):
-            yield extracheck, hash_name, expected
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to