diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_deque.py | 23 | ||||
-rw-r--r-- | Lib/test/test_set.py | 4 | ||||
-rw-r--r-- | Lib/test/test_signal.py | 19 |
3 files changed, 38 insertions, 8 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py index 12f77a9..c8d0c7e 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -64,8 +64,27 @@ class TestBasic(unittest.TestCase): self.assertEqual(list(d), [7, 8, 9]) d = deque(range(200), maxlen=10) d.append(d) + fo = open(test_support.TESTFN, "w") + try: + fo.write(str(d)) + fo.close() + fo = open(test_support.TESTFN, "r") + self.assertEqual(fo.read(), repr(d)) + finally: + fo.close() + test_support.unlink(test_support.TESTFN) + d = deque(range(10), maxlen=None) self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])') + fo = open(test_support.TESTFN, "w") + try: + fo.write(str(d)) + fo.close() + fo = open(test_support.TESTFN, "r") + self.assertEqual(fo.read(), repr(d)) + finally: + fo.close() + test_support.unlink(test_support.TESTFN) def test_comparisons(self): d = deque('xabc'); d.popleft() @@ -265,13 +284,13 @@ class TestBasic(unittest.TestCase): d.append(d) try: fo = open(test_support.TESTFN, "w") - fo.write(str(d)) + print(d, file=fo, end='') fo.close() fo = open(test_support.TESTFN, "r") self.assertEqual(fo.read(), repr(d)) finally: fo.close() - os.remove(test_support.TESTFN) + test_support.unlink(test_support.TESTFN) def test_init(self): self.assertRaises(TypeError, deque, 'abc', 2, 3); diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index ca3c02e..44a45af 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -295,7 +295,7 @@ class TestJointOps(unittest.TestCase): self.assertEqual(fo.read(), repr(s)) finally: fo.close() - os.remove(test_support.TESTFN) + test_support.unlink(test_support.TESTFN) def test_do_not_rehash_dict_keys(self): n = 10 @@ -679,7 +679,7 @@ class TestBasicOps(unittest.TestCase): self.assertEqual(fo.read(), repr(self.set)) finally: fo.close() - os.remove(test_support.TESTFN) + test_support.unlink(test_support.TESTFN) def test_length(self): self.assertEqual(len(self.set), self.length) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index 2cee626..3c039a1 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -1,6 +1,7 @@ import unittest from test import test_support from contextlib import closing, nested +import gc import pickle import select import signal @@ -30,6 +31,14 @@ def exit_subprocess(): class InterProcessSignalTests(unittest.TestCase): MAX_DURATION = 20 # Entire test should last at most 20 sec. + def setUp(self): + self.using_gc = gc.isenabled() + gc.disable() + + def tearDown(self): + if self.using_gc: + gc.enable() + def handlerA(self, *args): self.a_called = True if test_support.verbose: @@ -263,8 +272,10 @@ class ItimerTest(unittest.TestCase): self.hndl_called = False self.hndl_count = 0 self.itimer = None + self.old_alarm = signal.signal(signal.SIGALRM, self.sig_alrm) def tearDown(self): + signal.signal(signal.SIGALRM, self.old_alarm) if self.itimer is not None: # test_itimer_exc doesn't change this attr # just ensure that itimer is stopped signal.setitimer(self.itimer, 0) @@ -303,13 +314,13 @@ class ItimerTest(unittest.TestCase): # XXX I'm assuming -1 is an invalid itimer, but maybe some platform # defines it ? self.assertRaises(signal.ItimerError, signal.setitimer, -1, 0) - # negative time - self.assertRaises(signal.ItimerError, signal.setitimer, - signal.ITIMER_REAL, -1) + # Negative times are treated as zero on some platforms. + if 0: + self.assertRaises(signal.ItimerError, + signal.setitimer, signal.ITIMER_REAL, -1) def test_itimer_real(self): self.itimer = signal.ITIMER_REAL - signal.signal(signal.SIGALRM, self.sig_alrm) signal.setitimer(self.itimer, 1.0) if test_support.verbose: print("\ncall pause()...") |