annotate Lib/test/test_funcattrs.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents 6ffcdafa0118
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
1 from test import test_support
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
2 import types
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
3 import unittest
15893
553a315f58e9 Committing PEP 232, function attribute feature, approved by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
4
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
5 class FuncAttrsTest(unittest.TestCase):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
6 def setUp(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
7 class F:
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
8 def a(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
9 pass
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
10 def b():
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
11 return 3
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
12 self.f = F
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
13 self.fi = F()
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
14 self.b = b
15893
553a315f58e9 Committing PEP 232, function attribute feature, approved by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
15
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
16 def cannot_set_attr(self, obj, name, value, exceptions):
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
17 # Helper method for other tests.
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
18 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
19 setattr(obj, name, value)
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
20 except exceptions:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
21 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
22 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
23 self.fail("shouldn't be able to set %s to %r" % (name, value))
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
24 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
25 delattr(obj, name)
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
26 except exceptions:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
27 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
28 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
29 self.fail("shouldn't be able to del %s" % name)
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
30
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
31
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
32 class FunctionPropertiesTest(FuncAttrsTest):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
33 # Include the external setUp method that is common to all tests
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
34 def test_module(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
35 self.assertEqual(self.b.__module__, __name__)
16766
680c885dface Additional tests for current, PEP described semantics:
Barry Warsaw <barry@python.org>
parents: 16536
diff changeset
36
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
37 def test_dir_includes_correct_attrs(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
38 self.b.known_attr = 7
58460
17891566a478 use assert[Not]In where appropriate
Ezio Melotti <ezio.melotti@gmail.com>
parents: 55822
diff changeset
39 self.assertIn('known_attr', dir(self.b),
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
40 "set attributes not in dir listing of method")
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
41 # Test on underlying function object of method
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
42 self.f.a.im_func.known_attr = 7
58460
17891566a478 use assert[Not]In where appropriate
Ezio Melotti <ezio.melotti@gmail.com>
parents: 55822
diff changeset
43 self.assertIn('known_attr', dir(self.f.a),
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
44 "set attribute on unbound method implementation in "
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
45 "class not in dir")
58460
17891566a478 use assert[Not]In where appropriate
Ezio Melotti <ezio.melotti@gmail.com>
parents: 55822
diff changeset
46 self.assertIn('known_attr', dir(self.fi.a),
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
47 "set attribute on unbound method implementations, "
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
48 "should show up in next dir")
15893
553a315f58e9 Committing PEP 232, function attribute feature, approved by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
49
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
50 def test_duplicate_function_equality(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
51 # Body of `duplicate' is the exact same as self.b
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
52 def duplicate():
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
53 'my docstring'
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
54 return 3
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
55 self.assertNotEqual(self.b, duplicate)
15893
553a315f58e9 Committing PEP 232, function attribute feature, approved by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
56
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
57 def test_copying_func_code(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
58 def test(): pass
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
59 self.assertEqual(test(), None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
60 test.func_code = self.b.func_code
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
61 self.assertEqual(test(), 3) # self.b always returns 3, arbitrarily
15893
553a315f58e9 Committing PEP 232, function attribute feature, approved by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
62
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
63 def test_func_globals(self):
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
64 self.assertIs(self.b.func_globals, globals())
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
65 self.cannot_set_attr(self.b, 'func_globals', 2, TypeError)
16766
680c885dface Additional tests for current, PEP described semantics:
Barry Warsaw <barry@python.org>
parents: 16536
diff changeset
66
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
67 def test_func_closure(self):
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
68 a = 12
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
69 def f(): print a
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
70 c = f.func_closure
58472
6ffcdafa0118 use assert[Not]IsInstance where appropriate
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58460
diff changeset
71 self.assertIsInstance(c, tuple)
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
72 self.assertEqual(len(c), 1)
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
73 # don't have a type object handy
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
74 self.assertEqual(c[0].__class__.__name__, "cell")
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
75 self.cannot_set_attr(f, "func_closure", c, TypeError)
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
76
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
77 def test_empty_cell(self):
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
78 def f(): print a
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
79 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
80 f.func_closure[0].cell_contents
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
81 except ValueError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
82 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
83 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
84 self.fail("shouldn't be able to read an empty cell")
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
85 a = 12
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
86
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
87 def test_func_name(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
88 self.assertEqual(self.b.__name__, 'b')
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
89 self.assertEqual(self.b.func_name, 'b')
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
90 self.b.__name__ = 'c'
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
91 self.assertEqual(self.b.__name__, 'c')
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
92 self.assertEqual(self.b.func_name, 'c')
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
93 self.b.func_name = 'd'
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
94 self.assertEqual(self.b.__name__, 'd')
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
95 self.assertEqual(self.b.func_name, 'd')
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
96 # __name__ and func_name must be a string
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
97 self.cannot_set_attr(self.b, '__name__', 7, TypeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
98 self.cannot_set_attr(self.b, 'func_name', 7, TypeError)
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
99 # __name__ must be available when in restricted mode. Exec will raise
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
100 # AttributeError if __name__ is not available on f.
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
101 s = """def f(): pass\nf.__name__"""
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
102 exec s in {'__builtins__': {}}
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
103 # Test on methods, too
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
104 self.assertEqual(self.f.a.__name__, 'a')
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
105 self.assertEqual(self.fi.a.__name__, 'a')
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
106 self.cannot_set_attr(self.f.a, "__name__", 'a', AttributeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
107 self.cannot_set_attr(self.fi.a, "__name__", 'a', AttributeError)
15897
c568ba9dc180 Add a test case suggested by Guido, where a method is created with the
Barry Warsaw <barry@python.org>
parents: 15893
diff changeset
108
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
109 def test_func_code(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
110 num_one, num_two = 7, 8
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
111 def a(): pass
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
112 def b(): return 12
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
113 def c(): return num_one
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
114 def d(): return num_two
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
115 def e(): return num_one, num_two
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
116 for func in [a, b, c, d, e]:
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
117 self.assertEqual(type(func.func_code), types.CodeType)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
118 self.assertEqual(c(), 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
119 self.assertEqual(d(), 8)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
120 d.func_code = c.func_code
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
121 self.assertEqual(c.func_code, d.func_code)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
122 self.assertEqual(c(), 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
123 # self.assertEqual(d(), 7)
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
124 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
125 b.func_code = c.func_code
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
126 except ValueError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
127 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
128 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
129 self.fail("func_code with different numbers of free vars should "
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
130 "not be possible")
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
131 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
132 e.func_code = d.func_code
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
133 except ValueError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
134 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
135 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
136 self.fail("func_code with different numbers of free vars should "
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
137 "not be possible")
19245
3b98cf1692d4 Test the new semantics for setting and deleting a function's __dict__
Barry Warsaw <barry@python.org>
parents: 16766
diff changeset
138
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
139 def test_blank_func_defaults(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
140 self.assertEqual(self.b.func_defaults, None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
141 del self.b.func_defaults
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
142 self.assertEqual(self.b.func_defaults, None)
16043
8bac0659393e Add some regression tests of coredump bugs in funcobject.c 2.31. Also
Barry Warsaw <barry@python.org>
parents: 15897
diff changeset
143
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
144 def test_func_default_args(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
145 def first_func(a, b):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
146 return a+b
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
147 def second_func(a=1, b=2):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
148 return a+b
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
149 self.assertEqual(first_func.func_defaults, None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
150 self.assertEqual(second_func.func_defaults, (1, 2))
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
151 first_func.func_defaults = (1, 2)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
152 self.assertEqual(first_func.func_defaults, (1, 2))
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
153 self.assertEqual(first_func(), 3)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
154 self.assertEqual(first_func(3), 5)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
155 self.assertEqual(first_func(3, 5), 8)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
156 del second_func.func_defaults
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
157 self.assertEqual(second_func.func_defaults, None)
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
158 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
159 second_func()
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
160 except TypeError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
161 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
162 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
163 self.fail("func_defaults does not update; deleting it does not "
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
164 "remove requirement")
16043
8bac0659393e Add some regression tests of coredump bugs in funcobject.c 2.31. Also
Barry Warsaw <barry@python.org>
parents: 15897
diff changeset
165
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
166
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
167 class InstancemethodAttrTest(FuncAttrsTest):
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
168 def test_im_class(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
169 self.assertEqual(self.f.a.im_class, self.f)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
170 self.assertEqual(self.fi.a.im_class, self.f)
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
171 self.cannot_set_attr(self.f.a, "im_class", self.f, TypeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
172 self.cannot_set_attr(self.fi.a, "im_class", self.f, TypeError)
16328
abd383f1905c The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents: 16043
diff changeset
173
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
174 def test_im_func(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
175 self.f.b = self.b
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
176 self.assertEqual(self.f.b.im_func, self.b)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
177 self.assertEqual(self.fi.b.im_func, self.b)
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
178 self.cannot_set_attr(self.f.b, "im_func", self.b, TypeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
179 self.cannot_set_attr(self.fi.b, "im_func", self.b, TypeError)
16328
abd383f1905c The one thing I love more then writing code is deleting code.
Moshe Zadka <moshez@math.huji.ac.il>
parents: 16043
diff changeset
180
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
181 def test_im_self(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
182 self.assertEqual(self.f.a.im_self, None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
183 self.assertEqual(self.fi.a.im_self, self.fi)
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
184 self.cannot_set_attr(self.f.a, "im_self", None, TypeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
185 self.cannot_set_attr(self.fi.a, "im_self", self.fi, TypeError)
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
186
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
187 def test_im_func_non_method(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
188 # Behavior should be the same when a method is added via an attr
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
189 # assignment
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
190 self.f.id = types.MethodType(id, None, self.f)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
191 self.assertEqual(self.fi.id(), id(self.fi))
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
192 self.assertNotEqual(self.fi.id(), id(self.f))
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
193 # Test usage
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
194 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
195 self.f.id.unknown_attr
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
196 except AttributeError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
197 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
198 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
199 self.fail("using unknown attributes should raise AttributeError")
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
200 # Test assignment and deletion
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
201 self.cannot_set_attr(self.f.id, 'unknown_attr', 2, AttributeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
202 self.cannot_set_attr(self.fi.id, 'unknown_attr', 2, AttributeError)
19955
f36a2d40a1df - Some tests that check that assignments are not allowed expect this
Guido van Rossum <guido@python.org>
parents: 19948
diff changeset
203
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
204 def test_implicit_method_properties(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
205 self.f.a.im_func.known_attr = 7
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
206 self.assertEqual(self.f.a.known_attr, 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
207 self.assertEqual(self.fi.a.known_attr, 7)
44011
4cf9bb9cef91 Issue #1445: Fix a SystemError when accessing the ``cell_contents``
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 34598
diff changeset
208
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
209
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
210 class ArbitraryFunctionAttrTest(FuncAttrsTest):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
211 def test_set_attr(self):
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
212 # setting attributes only works on function objects
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
213 self.b.known_attr = 7
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
214 self.assertEqual(self.b.known_attr, 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
215 for func in [self.f.a, self.fi.a]:
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
216 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
217 func.known_attr = 7
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
218 except AttributeError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
219 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
220 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
221 self.fail("setting attributes on methods should raise error")
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
222
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
223 def test_delete_unknown_attr(self):
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
224 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
225 del self.b.unknown_attr
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
226 except AttributeError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
227 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
228 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
229 self.fail("deleting unknown attribute should raise TypeError")
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
230
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
231 def test_setting_attrs_duplicates(self):
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
232 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
233 self.f.a.klass = self.f
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
234 except AttributeError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
235 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
236 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
237 self.fail("setting arbitrary attribute in unbound function "
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
238 " should raise AttributeError")
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
239 self.f.a.im_func.klass = self.f
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
240 for method in [self.f.a, self.fi.a, self.fi.a.im_func]:
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
241 self.assertEqual(method.klass, self.f)
33116
3a4e73a5e434 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 33102
diff changeset
242
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
243 def test_unset_attr(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
244 for func in [self.b, self.f.a, self.fi.a]:
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
245 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
246 func.non_existent_attr
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
247 except AttributeError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
248 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
249 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
250 self.fail("using unknown attributes should raise "
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
251 "AttributeError")
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
252
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
253
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
254 class FunctionDictsTest(FuncAttrsTest):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
255 def test_setting_dict_to_invalid(self):
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
256 self.cannot_set_attr(self.b, '__dict__', None, TypeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
257 self.cannot_set_attr(self.b, 'func_dict', None, TypeError)
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
258 from UserDict import UserDict
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
259 d = UserDict({'known_attr': 7})
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
260 self.cannot_set_attr(self.f.a.im_func, '__dict__', d, TypeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
261 self.cannot_set_attr(self.fi.a.im_func, '__dict__', d, TypeError)
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
262
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
263 def test_setting_dict_to_valid(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
264 d = {'known_attr': 7}
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
265 self.b.__dict__ = d
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
266 # Setting dict is only possible on the underlying function objects
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
267 self.f.a.im_func.__dict__ = d
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
268 # Test assignment
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
269 self.assertIs(d, self.b.__dict__)
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
270 self.assertIs(d, self.b.func_dict)
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
271 # ... and on all the different ways of referencing the method's func
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
272 self.assertIs(d, self.f.a.im_func.__dict__)
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
273 self.assertIs(d, self.f.a.__dict__)
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
274 self.assertIs(d, self.fi.a.im_func.__dict__)
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
275 self.assertIs(d, self.fi.a.__dict__)
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
276 # Test value
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
277 self.assertEqual(self.b.known_attr, 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
278 self.assertEqual(self.b.__dict__['known_attr'], 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
279 self.assertEqual(self.b.func_dict['known_attr'], 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
280 # ... and again, on all the different method's names
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
281 self.assertEqual(self.f.a.im_func.known_attr, 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
282 self.assertEqual(self.f.a.known_attr, 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
283 self.assertEqual(self.fi.a.im_func.known_attr, 7)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
284 self.assertEqual(self.fi.a.known_attr, 7)
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
285
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
286 def test_delete_func_dict(self):
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
287 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
288 del self.b.__dict__
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
289 except TypeError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
290 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
291 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
292 self.fail("deleting function dictionary should raise TypeError")
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
293 try:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
294 del self.b.func_dict
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
295 except TypeError:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
296 pass
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
297 else:
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
298 self.fail("deleting function dictionary should raise TypeError")
19955
f36a2d40a1df - Some tests that check that assignments are not allowed expect this
Guido van Rossum <guido@python.org>
parents: 19948
diff changeset
299
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
300 def test_unassigned_dict(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
301 self.assertEqual(self.b.__dict__, {})
19955
f36a2d40a1df - Some tests that check that assignments are not allowed expect this
Guido van Rossum <guido@python.org>
parents: 19948
diff changeset
302
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
303 def test_func_as_dict_key(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
304 value = "Some string"
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
305 d = {}
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
306 d[self.b] = value
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
307 self.assertEqual(d[self.b], value)
19955
f36a2d40a1df - Some tests that check that assignments are not allowed expect this
Guido van Rossum <guido@python.org>
parents: 19948
diff changeset
308
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
309
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
310 class FunctionDocstringTest(FuncAttrsTest):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
311 def test_set_docstring_attr(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
312 self.assertEqual(self.b.__doc__, None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
313 self.assertEqual(self.b.func_doc, None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
314 docstr = "A test method that does nothing"
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
315 self.b.__doc__ = self.f.a.im_func.__doc__ = docstr
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
316 self.assertEqual(self.b.__doc__, docstr)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
317 self.assertEqual(self.b.func_doc, docstr)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
318 self.assertEqual(self.f.a.__doc__, docstr)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
319 self.assertEqual(self.fi.a.__doc__, docstr)
45175
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
320 self.cannot_set_attr(self.f.a, "__doc__", docstr, AttributeError)
1c2a26686e54 Fix unittest conversion breakage.
Georg Brandl <georg@python.org>
parents: 45105
diff changeset
321 self.cannot_set_attr(self.fi.a, "__doc__", docstr, AttributeError)
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
322
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
323 def test_delete_docstring(self):
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
324 self.b.__doc__ = "The docstring"
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
325 del self.b.__doc__
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
326 self.assertEqual(self.b.__doc__, None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
327 self.assertEqual(self.b.func_doc, None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
328 self.b.func_doc = "The docstring"
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
329 del self.b.func_doc
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
330 self.assertEqual(self.b.__doc__, None)
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
331 self.assertEqual(self.b.func_doc, None)
19948
eaf1203b85cf Rewrite function attributes to use the generic routines properly.
Guido van Rossum <guido@python.org>
parents: 19245
diff changeset
332
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
333
54414
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
334 class StaticMethodAttrsTest(unittest.TestCase):
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
335 def test_func_attribute(self):
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
336 def f():
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
337 pass
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
338
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
339 c = classmethod(f)
55002
6768b2350c57 convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents: 54414
diff changeset
340 self.assertTrue(c.__func__ is f)
54414
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
341
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
342 s = staticmethod(f)
55002
6768b2350c57 convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents: 54414
diff changeset
343 self.assertTrue(s.__func__ is f)
54414
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
344
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
345
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
346 def test_main():
55822
6758bf2002da #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups.
Georg Brandl <georg@python.org>
parents: 55002
diff changeset
347 test_support.run_unittest(FunctionPropertiesTest, InstancemethodAttrTest,
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
348 ArbitraryFunctionAttrTest, FunctionDictsTest,
54414
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
349 FunctionDocstringTest,
d75ab16413da Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.
Raymond Hettinger <python@rcn.com>
parents: 55049
diff changeset
350 StaticMethodAttrsTest)
45105
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
351
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
352 if __name__ == "__main__":
d54d133c6a8d Rewrite test_funcattrs as unittest, written for GHOP by Jeff Wheeler.
Georg Brandl <georg@python.org>
parents: 44034
diff changeset
353 test_main()