Test pretty print of function
()
| 436 | |
| 437 | |
| 438 | def test_function_pretty(): |
| 439 | "Test pretty print of function" |
| 440 | # posixpath is a pure python module, its interface is consistent |
| 441 | # across Python distributions |
| 442 | import posixpath |
| 443 | nt.assert_equal(pretty.pretty(posixpath.join), '<function posixpath.join(a, *p)>') |
| 444 | |
| 445 | # custom function |
| 446 | def meaning_of_life(question=None): |
| 447 | if question: |
| 448 | return 42 |
| 449 | return "Don't panic" |
| 450 | |
| 451 | nt.assert_in('meaning_of_life(question=None)', pretty.pretty(meaning_of_life)) |
| 452 | |
| 453 | |
| 454 | class OrderedCounter(Counter, OrderedDict): |