Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Delta Between Two Patch Sets: Lib/test/test_support.py

Issue 25695: test___all__ and test_support alter execution environment
Left Patch Set: Created 4 years, 4 months ago
Right Patch Set: Created 4 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 import importlib 1 import importlib
2 import shutil 2 import shutil
3 import sys 3 import sys
4 import os 4 import os
5 import unittest 5 import unittest
6 import socket 6 import socket
7 import tempfile 7 import tempfile
8 import errno 8 import errno
9 from test import support 9 from test import support
10 10
11 TESTFN = support.TESTFN 11 TESTFN = support.TESTFN
12 TESTDIRN = os.path.basename(tempfile.mkdtemp(dir='.'))
13 12
14 13
15 class TestSupport(unittest.TestCase): 14 class TestSupport(unittest.TestCase):
16 def setUp(self): 15 def setUp(self):
17 support.unlink(TESTFN) 16 support.unlink(TESTFN)
18 support.rmtree(TESTDIRN)
19 tearDown = setUp 17 tearDown = setUp
20 18
21 def test_import_module(self): 19 def test_import_module(self):
22 support.import_module("ftplib") 20 support.import_module("ftplib")
23 self.assertRaises(unittest.SkipTest, support.import_module, "foo") 21 self.assertRaises(unittest.SkipTest, support.import_module, "foo")
24 22
25 def test_import_fresh_module(self): 23 def test_import_fresh_module(self):
26 support.import_fresh_module("ftplib") 24 support.import_fresh_module("ftplib")
27 25
28 def test_get_attribute(self): 26 def test_get_attribute(self):
(...skipping 12 matching lines...) Expand all
41 self.assertNotIn("sched", sys.modules) 39 self.assertNotIn("sched", sys.modules)
42 40
43 def test_unlink(self): 41 def test_unlink(self):
44 with open(TESTFN, "w") as f: 42 with open(TESTFN, "w") as f:
45 pass 43 pass
46 support.unlink(TESTFN) 44 support.unlink(TESTFN)
47 self.assertFalse(os.path.exists(TESTFN)) 45 self.assertFalse(os.path.exists(TESTFN))
48 support.unlink(TESTFN) 46 support.unlink(TESTFN)
49 47
50 def test_rmtree(self): 48 def test_rmtree(self):
49 TESTDIRN = os.path.basename(tempfile.mkdtemp(dir='.'))
50 self.addCleanup(support.rmtree, TESTDIRN)
51 support.rmtree(TESTDIRN)
52
51 os.mkdir(TESTDIRN) 53 os.mkdir(TESTDIRN)
52 os.mkdir(os.path.join(TESTDIRN, TESTDIRN)) 54 os.mkdir(os.path.join(TESTDIRN, TESTDIRN))
53 support.rmtree(TESTDIRN) 55 support.rmtree(TESTDIRN)
54 self.assertFalse(os.path.exists(TESTDIRN)) 56 self.assertFalse(os.path.exists(TESTDIRN))
55 support.rmtree(TESTDIRN) 57 support.rmtree(TESTDIRN)
56 58
57 def test_forget(self): 59 def test_forget(self):
58 mod_filename = TESTFN + '.py' 60 mod_filename = TESTFN + '.py'
59 with open(mod_filename, 'w') as f: 61 with open(mod_filename, 'w') as f:
60 print('foo = 1', file=f) 62 print('foo = 1', file=f)
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 # skip_unless_symlink 363 # skip_unless_symlink
362 # SuppressCrashReport 364 # SuppressCrashReport
363 365
364 366
365 def test_main(): 367 def test_main():
366 tests = [TestSupport] 368 tests = [TestSupport]
367 support.run_unittest(*tests) 369 support.run_unittest(*tests)
368 370
369 if __name__ == '__main__': 371 if __name__ == '__main__':
370 test_main() 372 test_main()
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+