Issue #7830: Flatten nested functools.partial.

This commit is contained in:
Alexander Belopolsky 2015-03-01 15:08:17 -05:00
parent e2e178e081
commit e49af34151
4 changed files with 68 additions and 7 deletions

View file

@ -131,6 +131,16 @@ class TestPartial:
join = self.partial(''.join)
self.assertEqual(join(data), '0123456789')
def test_nested_optimization(self):
partial = self.partial
# Only "true" partial is optimized
if partial.__name__ != 'partial':
return
inner = partial(signature, 'asdf')
nested = partial(inner, bar=True)
flat = partial(signature, 'asdf', bar=True)
self.assertEqual(signature(nested), signature(flat))
@unittest.skipUnless(c_functools, 'requires the C _functools module')
class TestPartialC(TestPartial, unittest.TestCase):