Show More
@@ -384,6 +384,22 b' class InteractiveShellTestCase(unittest.TestCase):' | |||
|
384 | 384 | finally: |
|
385 | 385 | # Reset the custom exception hook |
|
386 | 386 | ip.set_custom_exc((), None) |
|
387 | ||
|
388 | @skipif(sys.version_info[0] >= 3, "no differences with __future__ in py3") | |
|
389 | def test_future_environment(self): | |
|
390 | "Can we run code with & without the shell's __future__ imports?" | |
|
391 | ip.run_cell("from __future__ import division") | |
|
392 | ip.run_cell("a = 1/2", shell_futures=True) | |
|
393 | self.assertEqual(ip.user_ns['a'], 0.5) | |
|
394 | ip.run_cell("b = 1/2", shell_futures=False) | |
|
395 | self.assertEqual(ip.user_ns['b'], 0) | |
|
396 | ||
|
397 | ip.compile.reset_compiler_flags() | |
|
398 | # This shouldn't leak to the shell's compiler | |
|
399 | ip.run_cell("from __future__ import division \nc=1/2", shell_futures=False) | |
|
400 | self.assertEqual(ip.user_ns['c'], 0.5) | |
|
401 | ip.run_cell("d = 1/2", shell_futures=True) | |
|
402 | self.assertEqual(ip.user_ns['d'], 0) | |
|
387 | 403 | |
|
388 | 404 | |
|
389 | 405 | class TestSafeExecfileNonAsciiPath(unittest.TestCase): |
General Comments 0
You need to be logged in to leave comments.
Login now