[pypy-commit] pypy default: run the getattr tests under the getattributeshortcut optimization too
pjenvey
noreply at buildbot.pypy.org
Wed Oct 10 23:57:55 CEST 2012
Author: Philip Jenvey <pjenvey at underboss.org>
Branch:
Changeset: r57994:a858967c9ad0
Date: 2012-10-10 14:57 -0700
http://bitbucket.org/pypy/pypy/changeset/a858967c9ad0/
Log: run the getattr tests under the getattributeshortcut optimization
too
diff --git a/pypy/module/__builtin__/test/test_builtin.py b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -172,28 +172,6 @@
assert f() == {}
assert g() == {'a':0, 'b':0, 'c':0}
- def test_getattr(self):
- class a(object):
- i = 5
- assert getattr(a, 'i') == 5
- raises(AttributeError, getattr, a, 'k')
- assert getattr(a, 'k', 42) == 42
- assert getattr(a, u'i') == 5
- raises(AttributeError, getattr, a, u'k')
- assert getattr(a, u'k', 42) == 42
-
- def test_getattr_typecheck(self):
- class A(object):
- def __getattribute__(self, name):
- pass
- def __setattr__(self, name, value):
- pass
- def __delattr__(self, name):
- pass
- raises(TypeError, getattr, A(), 42)
- raises(TypeError, setattr, A(), 42, 'x')
- raises(TypeError, delattr, A(), 42)
-
def test_sum(self):
assert sum([]) ==0
assert sum([42]) ==42
@@ -661,6 +639,39 @@
assert vars(C_get_vars()) == {'a':2}
+class AppTestGetattr:
+ OPTIONS = {}
+
+ def setup_class(cls):
+ cls.space = conftest.gettestobjspace(**cls.OPTIONS)
+
+ def test_getattr(self):
+ class a(object):
+ i = 5
+ assert getattr(a, 'i') == 5
+ raises(AttributeError, getattr, a, 'k')
+ assert getattr(a, 'k', 42) == 42
+ assert getattr(a, u'i') == 5
+ raises(AttributeError, getattr, a, u'k')
+ assert getattr(a, u'k', 42) == 42
+
+ def test_getattr_typecheck(self):
+ class A(object):
+ def __getattribute__(self, name):
+ pass
+ def __setattr__(self, name, value):
+ pass
+ def __delattr__(self, name):
+ pass
+ raises(TypeError, getattr, A(), 42)
+ raises(TypeError, setattr, A(), 42, 'x')
+ raises(TypeError, delattr, A(), 42)
+
+
+class AppTestGetattrWithGetAttributeShortcut(AppTestGetattr):
+ OPTIONS = {"objspace.std.getattributeshortcut": True}
+
+
class TestInternal:
def test_execfile(self, space):
from pypy.tool.udir import udir
More information about the pypy-commit
mailing list