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

Side by Side Diff: Lib/distutils/tests/test_build_scripts.py

Issue 19600: Use specific asserts in distutils tests
Patch Set: Created 5 years, 12 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:
View unified diff | Download patch
OLDNEW
1 """Tests for distutils.command.build_scripts.""" 1 """Tests for distutils.command.build_scripts."""
2 2
3 import os 3 import os
4 import unittest 4 import unittest
5 5
6 from distutils.command.build_scripts import build_scripts 6 from distutils.command.build_scripts import build_scripts
7 from distutils.core import Distribution 7 from distutils.core import Distribution
8 from distutils import sysconfig 8 from distutils import sysconfig
9 9
10 from distutils.tests import support 10 from distutils.tests import support
11 from test.support import run_unittest 11 from test.support import run_unittest
12 12
13 13
14 class BuildScriptsTestCase(support.TempdirManager, 14 class BuildScriptsTestCase(support.TempdirManager,
15 support.LoggingSilencer, 15 support.LoggingSilencer,
16 unittest.TestCase): 16 unittest.TestCase):
17 17
18 def test_default_settings(self): 18 def test_default_settings(self):
19 cmd = self.get_build_scripts_cmd("/foo/bar", []) 19 cmd = self.get_build_scripts_cmd("/foo/bar", [])
20 self.assertTrue(not cmd.force) 20 self.assertFalse(cmd.force)
21 self.assertTrue(cmd.build_dir is None) 21 self.assertIsNone(cmd.build_dir)
22 22
23 cmd.finalize_options() 23 cmd.finalize_options()
24 24
25 self.assertTrue(cmd.force) 25 self.assertTrue(cmd.force)
26 self.assertEqual(cmd.build_dir, "/foo/bar") 26 self.assertEqual(cmd.build_dir, "/foo/bar")
27 27
28 def test_build(self): 28 def test_build(self):
29 source = self.mkdtemp() 29 source = self.mkdtemp()
30 target = self.mkdtemp() 30 target = self.mkdtemp()
31 expected = self.write_sample_scripts(source) 31 expected = self.write_sample_scripts(source)
32 32
33 cmd = self.get_build_scripts_cmd(target, 33 cmd = self.get_build_scripts_cmd(target,
34 [os.path.join(source, fn) 34 [os.path.join(source, fn)
35 for fn in expected]) 35 for fn in expected])
36 cmd.finalize_options() 36 cmd.finalize_options()
37 cmd.run() 37 cmd.run()
38 38
39 built = os.listdir(target) 39 built = os.listdir(target)
40 for name in expected: 40 for name in expected:
41 self.assertTrue(name in built) 41 self.assertIn(name, built)
42 42
43 def get_build_scripts_cmd(self, target, scripts): 43 def get_build_scripts_cmd(self, target, scripts):
44 import sys 44 import sys
45 dist = Distribution() 45 dist = Distribution()
46 dist.scripts = scripts 46 dist.scripts = scripts
47 dist.command_obj["build"] = support.DummyCommand( 47 dist.command_obj["build"] = support.DummyCommand(
48 build_scripts=target, 48 build_scripts=target,
49 force=1, 49 force=1,
50 executable=sys.executable 50 executable=sys.executable
51 ) 51 )
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 old = sysconfig.get_config_vars().get('VERSION') 96 old = sysconfig.get_config_vars().get('VERSION')
97 sysconfig._config_vars['VERSION'] = 4 97 sysconfig._config_vars['VERSION'] = 4
98 try: 98 try:
99 cmd.run() 99 cmd.run()
100 finally: 100 finally:
101 if old is not None: 101 if old is not None:
102 sysconfig._config_vars['VERSION'] = old 102 sysconfig._config_vars['VERSION'] = old
103 103
104 built = os.listdir(target) 104 built = os.listdir(target)
105 for name in expected: 105 for name in expected:
106 self.assertTrue(name in built) 106 self.assertIn(name, built)
107 107
108 def test_suite(): 108 def test_suite():
109 return unittest.makeSuite(BuildScriptsTestCase) 109 return unittest.makeSuite(BuildScriptsTestCase)
110 110
111 if __name__ == "__main__": 111 if __name__ == "__main__":
112 run_unittest(test_suite()) 112 run_unittest(test_suite())
OLDNEW

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