Skip to content

Commit b1902b9

Browse files
committed
Don't remove directories unless told to.
1 parent 9119930 commit b1902b9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

setupext/janitor/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def initialize_options(self):
4646

4747
def run(self):
4848
_CleanCommand.run(self)
49+
if not self.dist:
50+
return
51+
4952
dist_dirs = set()
5053
for cmd_name in self.distribution.commands:
5154
if 'dist' in cmd_name:

tests.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ def setUpClass(cls):
8181

8282
@classmethod
8383
def create_directory(cls, dir_name):
84-
full_path = os.path.join(cls.temp_dir, dir_name)
85-
os.mkdir(full_path)
86-
return full_path
84+
return tempfile.mkdtemp(dir=cls.temp_dir, prefix=dir_name)
8785

8886
def assert_path_does_not_exist(self, full_path):
8987
if os.path.exists(full_path):
9088
raise AssertionError('{0} should not exist'.format(full_path))
9189

90+
def assert_path_exists(self, full_path):
91+
if not os.path.exists(full_path):
92+
raise AssertionError('{0} should exist'.format(full_path))
93+
9294
def test_that_dist_directory_is_removed_for_sdist(self):
9395
dist_dir = self.create_directory('dist-dir')
9496
run_setup(
@@ -115,3 +117,14 @@ def test_that_multiple_dist_directories_with_be_removed(self):
115117
)
116118
self.assert_path_does_not_exist(sdist_dir)
117119
self.assert_path_does_not_exist(bdist_dir)
120+
121+
def test_that_directories_are_not_removed_without_parameter(self):
122+
sdist_dir = self.create_directory('sdist-dir')
123+
bdist_dir = self.create_directory('bdist_dumb')
124+
run_setup(
125+
'sdist', '--dist-dir={0}'.format(sdist_dir),
126+
'bdist_dumb', '--dist-dir={0}'.format(bdist_dir),
127+
'clean',
128+
)
129+
self.assert_path_exists(sdist_dir)
130+
self.assert_path_exists(bdist_dir)

0 commit comments

Comments
 (0)