1 """Tests for distutils.command.clean."""
7 from distutils
.command
.clean
import clean
8 from distutils
.tests
import support
10 class cleanTestCase(support
.TempdirManager
,
11 support
.LoggingSilencer
,
14 def test_simple_run(self
):
15 pkg_dir
, dist
= self
.create_dist()
18 # let's add some elements clean should remove
19 dirs
= [(d
, os
.path
.join(pkg_dir
, d
))
20 for d
in ('build_temp', 'build_lib', 'bdist_base',
21 'build_scripts', 'build_base')]
23 for name
, path
in dirs
:
25 setattr(cmd
, name
, path
)
26 if name
== 'build_base':
28 for f
in ('one', 'two', 'three'):
29 self
.write_file(os
.path
.join(path
, f
))
31 # let's run the command
33 cmd
.ensure_finalized()
36 # make sure the files where removed
37 for name
, path
in dirs
:
38 self
.assertTrue(not os
.path
.exists(path
),
39 '%s was not removed' % path
)
41 # let's run the command again (should spit warnings but suceed)
43 cmd
.ensure_finalized()
47 return unittest
.makeSuite(cleanTestCase
)
49 if __name__
== "__main__":
50 unittest
.main(defaultTest
="test_suite")