Show More
@@ -530,6 +530,10 b' class TestSafeExecfileNonAsciiPath(unittest.TestCase):' | |||||
530 | ip.safe_execfile(self.fname, {}, raise_exceptions=True) |
|
530 | ip.safe_execfile(self.fname, {}, raise_exceptions=True) | |
531 |
|
531 | |||
532 | class ExitCodeChecks(tt.TempFileMixin): |
|
532 | class ExitCodeChecks(tt.TempFileMixin): | |
|
533 | ||||
|
534 | def setUp(self): | |||
|
535 | self.system = ip.system_raw | |||
|
536 | ||||
533 | def test_exit_code_ok(self): |
|
537 | def test_exit_code_ok(self): | |
534 | self.system('exit 0') |
|
538 | self.system('exit 0') | |
535 | self.assertEqual(ip.user_ns['_exit_code'], 0) |
|
539 | self.assertEqual(ip.user_ns['_exit_code'], 0) | |
@@ -559,8 +563,11 b' class ExitCodeChecks(tt.TempFileMixin):' | |||||
559 | del os.environ['SHELL'] |
|
563 | del os.environ['SHELL'] | |
560 |
|
564 | |||
561 |
|
565 | |||
562 |
class TestSystemRaw(ExitCodeChecks |
|
566 | class TestSystemRaw(ExitCodeChecks): | |
563 | system = ip.system_raw |
|
567 | ||
|
568 | def setUp(self): | |||
|
569 | super().setUp() | |||
|
570 | self.sytem = ip.system_raw | |||
564 |
|
571 | |||
565 | @onlyif_unicode_paths |
|
572 | @onlyif_unicode_paths | |
566 | def test_1(self): |
|
573 | def test_1(self): | |
@@ -580,8 +587,11 b' class TestSystemRaw(ExitCodeChecks, unittest.TestCase):' | |||||
580 | self.assertEqual(ip.user_ns['_exit_code'], -signal.SIGINT) |
|
587 | self.assertEqual(ip.user_ns['_exit_code'], -signal.SIGINT) | |
581 |
|
588 | |||
582 | # TODO: Exit codes are currently ignored on Windows. |
|
589 | # TODO: Exit codes are currently ignored on Windows. | |
583 |
class TestSystemPipedExitCode(ExitCodeChecks |
|
590 | class TestSystemPipedExitCode(ExitCodeChecks): | |
584 | system = ip.system_piped |
|
591 | ||
|
592 | def setUp(self): | |||
|
593 | super().setUp() | |||
|
594 | self.sytem = ip.system_piped | |||
585 |
|
595 | |||
586 | @skip_win32 |
|
596 | @skip_win32 | |
587 | def test_exit_code_ok(self): |
|
597 | def test_exit_code_ok(self): | |
@@ -595,7 +605,7 b' class TestSystemPipedExitCode(ExitCodeChecks, unittest.TestCase):' | |||||
595 | def test_exit_code_signal(self): |
|
605 | def test_exit_code_signal(self): | |
596 | ExitCodeChecks.test_exit_code_signal(self) |
|
606 | ExitCodeChecks.test_exit_code_signal(self) | |
597 |
|
607 | |||
598 |
class TestModules(tt.TempFileMixin |
|
608 | class TestModules(tt.TempFileMixin): | |
599 | def test_extraneous_loads(self): |
|
609 | def test_extraneous_loads(self): | |
600 | """Test we're not loading modules on startup that we shouldn't. |
|
610 | """Test we're not loading modules on startup that we shouldn't. | |
601 | """ |
|
611 | """ | |
@@ -944,7 +954,7 b' def wrn():' | |||||
944 |
|
954 | |||
945 | class TestImportNoDeprecate(tt.TempFileMixin): |
|
955 | class TestImportNoDeprecate(tt.TempFileMixin): | |
946 |
|
956 | |||
947 |
def set |
|
957 | def setUp(self): | |
948 | """Make a valid python temp file.""" |
|
958 | """Make a valid python temp file.""" | |
949 | self.mktmp(""" |
|
959 | self.mktmp(""" | |
950 | import warnings |
|
960 | import warnings | |
@@ -954,6 +964,7 b' def wrn():' | |||||
954 | DeprecationWarning |
|
964 | DeprecationWarning | |
955 | ) |
|
965 | ) | |
956 | """) |
|
966 | """) | |
|
967 | super().setUp() | |||
957 |
|
968 | |||
958 | def test_no_dep(self): |
|
969 | def test_no_dep(self): | |
959 | """ |
|
970 | """ |
@@ -165,7 +165,7 b' def doctest_reset_del():' | |||||
165 |
|
165 | |||
166 | class TestMagicRunPass(tt.TempFileMixin): |
|
166 | class TestMagicRunPass(tt.TempFileMixin): | |
167 |
|
167 | |||
168 |
def set |
|
168 | def setUp(self): | |
169 | content = "a = [1,2,3]\nb = 1" |
|
169 | content = "a = [1,2,3]\nb = 1" | |
170 | self.mktmp(content) |
|
170 | self.mktmp(content) | |
171 |
|
171 |
@@ -24,6 +24,8 b' from io import StringIO' | |||||
24 | import nose.tools as nt |
|
24 | import nose.tools as nt | |
25 | import IPython.testing.tools as tt |
|
25 | import IPython.testing.tools as tt | |
26 |
|
26 | |||
|
27 | from unittest import TestCase | |||
|
28 | ||||
27 | from IPython.testing.decorators import skipif |
|
29 | from IPython.testing.decorators import skipif | |
28 |
|
30 | |||
29 | from IPython.extensions.autoreload import AutoreloadMagics |
|
31 | from IPython.extensions.autoreload import AutoreloadMagics | |
@@ -63,7 +65,7 b' class FakeShell:' | |||||
63 | self.auto_magics.post_execute_hook() |
|
65 | self.auto_magics.post_execute_hook() | |
64 |
|
66 | |||
65 |
|
67 | |||
66 |
class Fixture( |
|
68 | class Fixture(TestCase): | |
67 | """Fixture for creating test module files""" |
|
69 | """Fixture for creating test module files""" | |
68 |
|
70 | |||
69 | test_dir = None |
|
71 | test_dir = None |
@@ -85,7 +85,7 b' class TestAssertPrints(unittest.TestCase):' | |||||
85 | self.assertRaises(AssertionError, func) |
|
85 | self.assertRaises(AssertionError, func) | |
86 |
|
86 | |||
87 |
|
87 | |||
88 |
class Test_ipexec_validate( |
|
88 | class Test_ipexec_validate(tt.TempFileMixin): | |
89 | def test_main_path(self): |
|
89 | def test_main_path(self): | |
90 | """Test with only stdout results. |
|
90 | """Test with only stdout results. | |
91 | """ |
|
91 | """ |
@@ -13,6 +13,7 b' import os' | |||||
13 | import re |
|
13 | import re | |
14 | import sys |
|
14 | import sys | |
15 | import tempfile |
|
15 | import tempfile | |
|
16 | import unittest | |||
16 |
|
17 | |||
17 | from contextlib import contextmanager |
|
18 | from contextlib import contextmanager | |
18 | from io import StringIO |
|
19 | from io import StringIO | |
@@ -262,7 +263,7 b" def ipexec_validate(fname, expected_out, expected_err=''," | |||||
262 | nt.assert_equal("\n".join(out.strip().splitlines()), "\n".join(expected_out.strip().splitlines())) |
|
263 | nt.assert_equal("\n".join(out.strip().splitlines()), "\n".join(expected_out.strip().splitlines())) | |
263 |
|
264 | |||
264 |
|
265 | |||
265 |
class TempFileMixin( |
|
266 | class TempFileMixin(unittest.TestCase): | |
266 | """Utility class to create temporary Python/IPython files. |
|
267 | """Utility class to create temporary Python/IPython files. | |
267 |
|
268 | |||
268 | Meant as a mixin class for test cases.""" |
|
269 | Meant as a mixin class for test cases.""" |
@@ -90,7 +90,7 b' def test_arg_split_win32():' | |||||
90 | nt.assert_equal(arg_split(argstr), argv) |
|
90 | nt.assert_equal(arg_split(argstr), argv) | |
91 |
|
91 | |||
92 |
|
92 | |||
93 |
class SubProcessTestCase( |
|
93 | class SubProcessTestCase(tt.TempFileMixin): | |
94 | def setUp(self): |
|
94 | def setUp(self): | |
95 | """Make a valid python temp file.""" |
|
95 | """Make a valid python temp file.""" | |
96 | lines = [ "import sys", |
|
96 | lines = [ "import sys", |
General Comments 0
You need to be logged in to leave comments.
Login now