reset must clear most namespaces.
()
| 14 | #----------------------------------------------------------------------------- |
| 15 | |
| 16 | def test_reset(): |
| 17 | """reset must clear most namespaces.""" |
| 18 | |
| 19 | # Check that reset runs without error |
| 20 | ip.reset() |
| 21 | |
| 22 | # Once we've reset it (to clear of any junk that might have been there from |
| 23 | # other tests, we can count how many variables are in the user's namespace |
| 24 | nvars_user_ns = len(ip.user_ns) |
| 25 | nvars_hidden = len(ip.user_ns_hidden) |
| 26 | |
| 27 | # Now add a few variables to user_ns, and check that reset clears them |
| 28 | ip.user_ns['x'] = 1 |
| 29 | ip.user_ns['y'] = 1 |
| 30 | ip.reset() |
| 31 | |
| 32 | # Finally, check that all namespaces have only as many variables as we |
| 33 | # expect to find in them: |
| 34 | nt.assert_equal(len(ip.user_ns), nvars_user_ns) |
| 35 | nt.assert_equal(len(ip.user_ns_hidden), nvars_hidden) |
| 36 | |
| 37 | |
| 38 | # Tests for reporting of exceptions in various modes, handling of SystemExit, |