diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2021-11-10 12:12:49 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2021-11-10 12:13:40 -0500 |
| commit | 958ce2304e153b274e2ff7b40b1e7d5ddd214904 (patch) | |
| tree | bb1b77cfc08c31fb69eebdb0c66f5c0dde3f5223 /setuptools/_distutils/tests/test_clean.py | |
| parent | 23f63dd44c5d9f75de195833d25a5f2872220c2b (diff) | |
| parent | 8af23a41194ae747faf3e60f9cc19141b5e7ad24 (diff) | |
| download | python-setuptools-git-958ce2304e153b274e2ff7b40b1e7d5ddd214904.tar.gz | |
Merge pull request #2866 into main.
Diffstat (limited to 'setuptools/_distutils/tests/test_clean.py')
| -rw-r--r-- | setuptools/_distutils/tests/test_clean.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/setuptools/_distutils/tests/test_clean.py b/setuptools/_distutils/tests/test_clean.py new file mode 100644 index 00000000..c605afd8 --- /dev/null +++ b/setuptools/_distutils/tests/test_clean.py @@ -0,0 +1,49 @@ +"""Tests for distutils.command.clean.""" +import os +import unittest + +from distutils.command.clean import clean +from distutils.tests import support +from test.support import run_unittest + +class cleanTestCase(support.TempdirManager, + support.LoggingSilencer, + unittest.TestCase): + + def test_simple_run(self): + pkg_dir, dist = self.create_dist() + cmd = clean(dist) + + # let's add some elements clean should remove + dirs = [(d, os.path.join(pkg_dir, d)) + for d in ('build_temp', 'build_lib', 'bdist_base', + 'build_scripts', 'build_base')] + + for name, path in dirs: + os.mkdir(path) + setattr(cmd, name, path) + if name == 'build_base': + continue + for f in ('one', 'two', 'three'): + self.write_file(os.path.join(path, f)) + + # let's run the command + cmd.all = 1 + cmd.ensure_finalized() + cmd.run() + + # make sure the files where removed + for name, path in dirs: + self.assertFalse(os.path.exists(path), + '%s was not removed' % path) + + # let's run the command again (should spit warnings but succeed) + cmd.all = 1 + cmd.ensure_finalized() + cmd.run() + +def test_suite(): + return unittest.makeSuite(cleanTestCase) + +if __name__ == "__main__": + run_unittest(test_suite()) |
