Commits

Philip Jenvey  committed 8bdff3f

fix tests under -A, attrgetter now fails fast

  • Participants
  • Parent commits e75dafc
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/module/operator/app_operator.py

 
 def single_attr_getter(attr):
     if not isinstance(attr, str):
-        def _raise_typeerror(obj):
-            raise TypeError("argument must be a string, not %r" %
-                            (type(attr).__name__,))
-        return _raise_typeerror
+        raise TypeError("attribute name must be a string, not {!r}".format(
+                type(attr).__name__))
     #
     def make_getter(name, prevfn=None):
         if prevfn is None:

File pypy/module/operator/test/test_operator.py

         assert a.getx(a) == 5
         assert a.get3("foobar") == "b"
         assert a.getx(*(a,)) == 5
-        assert a.get3(obj="foobar") == "b"
-        
 
     def test_getter_multiple_gest(self):
         import operator
         a.z = 'Z'
 
         assert operator.attrgetter('x','z','y')(a) == ('X', 'Z', 'Y')
-        raises(TypeError, operator.attrgetter('x', (), 'y'), a)
+        raises(TypeError, operator.attrgetter, ('x', (), 'y'))
 
         data = list(map(str, range(20)))
         assert operator.itemgetter(2,10,5)(data) == ('2', '10', '5')
         raises(TypeError, operator.itemgetter(2, 'x', 5), data)
 
+    def test_attrgetter(self):
+        import operator
+        raises(TypeError, operator.attrgetter, 2)
+
     def test_dotted_attrgetter(self):
         from operator import attrgetter
         class A: