MCPcopy Index your code
hub / github.com/python/cpython / test_argforms

Method test_argforms

Lib/test/test_decorators.py:114–139  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

112 self.assertEqual(foo.author, 'Cleese')
113
114 def test_argforms(self):
115 # A few tests of argument passing, as we use restricted form
116 # of expressions for decorators.
117
118 def noteargs(*args, **kwds):
119 def decorate(func):
120 setattr(func, 'dbval', (args, kwds))
121 return func
122 return decorate
123
124 args = ( 'Now', 'is', 'the', 'time' )
125 kwds = dict(one=1, two=2)
126 @noteargs(*args, **kwds)
127 def f1(): return 42
128 self.assertEqual(f1(), 42)
129 self.assertEqual(f1.dbval, (args, kwds))
130
131 @noteargs('terry', 'gilliam', eric='idle', john='cleese')
132 def f2(): return 84
133 self.assertEqual(f2(), 84)
134 self.assertEqual(f2.dbval, (('terry', 'gilliam'),
135 dict(eric='idle', john='cleese')))
136
137 @noteargs(1, 2,)
138 def f3(): pass
139 self.assertEqual(f3.dbval, ((1, 2), {}))
140
141 def test_dbcheck(self):
142 @dbcheck('args[1] is not None')

Callers

nothing calls this directly

Calls 3

f1Function · 0.85
f2Function · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected