Skip to content

Commit

Permalink
Clean up after setuptools
Browse files Browse the repository at this point in the history
Setuptools 'clean' command doesn't work...

  pypa/setuptools#1347

Cleaning up after the turds it creates when we run our tests.
  • Loading branch information
atagar committed Apr 10, 2020
1 parent d38feee commit d1174a8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/integ/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from stem.util.test_tools import asynchronous

BASE_INSTALL_PATH = '/tmp/stem_test'
DIST_PATH = os.path.join(test.STEM_BASE, 'dist')
PYTHON_EXE = sys.executable if sys.executable else 'python'
INSTALL_MISMATCH_MSG = "Running 'python setup.py sdist' doesn't match our git contents in the following way. The manifest in our setup.py may need to be updated...\n\n"
SETUPTOOLS_LITTER = ('dist', 'stem.egg-info', 'stem_dry_run.egg-info') # setuptools cruft its 'clean' command won't clean up


def _assert_has_all_files(path):
Expand Down Expand Up @@ -117,8 +117,11 @@ def test_install():
if os.path.exists(BASE_INSTALL_PATH):
shutil.rmtree(BASE_INSTALL_PATH)

if os.path.exists(DIST_PATH):
shutil.rmtree(DIST_PATH)
for directory in SETUPTOOLS_LITTER:
path = os.path.join(test.STEM_BASE, directory)

if os.path.exists(path):
shutil.rmtree(path)

@asynchronous
def test_sdist(dependency_pid):
Expand Down Expand Up @@ -148,7 +151,7 @@ def test_sdist(dependency_pid):

# tarball has a prefix 'stem-[verion]' directory so stipping that out

dist_content = glob.glob('%s/*' % DIST_PATH)
dist_content = glob.glob('%s/*' % os.path.join(test.STEM_BASE, 'dist'))

if len(dist_content) != 1:
raise AssertionError('We should only have a single file in our dist directory, but instead had: %s' % ', '.join(dist_content))
Expand All @@ -169,5 +172,8 @@ def test_sdist(dependency_pid):
if issues:
raise AssertionError(INSTALL_MISMATCH_MSG + '\n'.join(issues))
finally:
if os.path.exists(DIST_PATH):
shutil.rmtree(DIST_PATH)
for directory in SETUPTOOLS_LITTER:
path = os.path.join(test.STEM_BASE, directory)

if os.path.exists(path):
shutil.rmtree(path)

0 comments on commit d1174a8

Please sign in to comment.