Debian Codegraph @

lib-python/3/distutils/tests/test_clean.py

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