ยปCore Development>Code coverage>Lib/distutils/tests/test_clean.py

Python code coverage for Lib/distutils/tests/test_clean.py

#countcontent
1n/a"""Tests for distutils.command.clean."""
2n/aimport os
3n/aimport unittest
4n/a
5n/afrom distutils.command.clean import clean
6n/afrom distutils.tests import support
7n/afrom test.support import run_unittest
8n/a
9n/aclass cleanTestCase(support.TempdirManager,
10n/a support.LoggingSilencer,
11n/a unittest.TestCase):
12n/a
13n/a def test_simple_run(self):
14n/a pkg_dir, dist = self.create_dist()
15n/a cmd = clean(dist)
16n/a
17n/a # let's add some elements clean should remove
18n/a dirs = [(d, os.path.join(pkg_dir, d))
19n/a for d in ('build_temp', 'build_lib', 'bdist_base',
20n/a 'build_scripts', 'build_base')]
21n/a
22n/a for name, path in dirs:
23n/a os.mkdir(path)
24n/a setattr(cmd, name, path)
25n/a if name == 'build_base':
26n/a continue
27n/a for f in ('one', 'two', 'three'):
28n/a self.write_file(os.path.join(path, f))
29n/a
30n/a # let's run the command
31n/a cmd.all = 1
32n/a cmd.ensure_finalized()
33n/a cmd.run()
34n/a
35n/a # make sure the files where removed
36n/a for name, path in dirs:
37n/a self.assertFalse(os.path.exists(path),
38n/a '%s was not removed' % path)
39n/a
40n/a # let's run the command again (should spit warnings but succeed)
41n/a cmd.all = 1
42n/a cmd.ensure_finalized()
43n/a cmd.run()
44n/a
45n/adef test_suite():
46n/a return unittest.makeSuite(cleanTestCase)
47n/a
48n/aif __name__ == "__main__":
49n/a run_unittest(test_suite())