(self)
| 271 | self.assertEqual(pickle_depickle(f2, protocol=self.protocol)(1), 1) |
| 272 | |
| 273 | def test_recursive_closure(self): |
| 274 | def f1(): |
| 275 | def g(): |
| 276 | return g |
| 277 | |
| 278 | return g |
| 279 | |
| 280 | def f2(base): |
| 281 | def g(n): |
| 282 | return base if n <= 1 else n * g(n - 1) |
| 283 | |
| 284 | return g |
| 285 | |
| 286 | g1 = pickle_depickle(f1(), protocol=self.protocol) |
| 287 | self.assertEqual(g1(), g1) |
| 288 | |
| 289 | g2 = pickle_depickle(f2(2), protocol=self.protocol) |
| 290 | self.assertEqual(g2(5), 240) |
| 291 | |
| 292 | def test_closure_none_is_preserved(self): |
| 293 | def f(): |
nothing calls this directly
no test coverage detected