Clean up some idioms in packaging tests.
- Use os.makedirs (I had forgotten about it!)
- Let TempdirManager.write_file call os.path.join for us
- Remove custom command added by test_dist
- Use a skip instead of hiding a method with an underscore
- Address pyflakes warnings
diff --git a/Lib/packaging/tests/test_command_install_dist.py b/Lib/packaging/tests/test_command_install_dist.py
index 496a3d8..3345d2e 100644
--- a/Lib/packaging/tests/test_command_install_dist.py
+++ b/Lib/packaging/tests/test_command_install_dist.py
@@ -93,21 +93,20 @@
self.old_expand = os.path.expanduser
os.path.expanduser = _expanduser
- try:
- # this is the actual test
- self._test_user_site()
- finally:
+ def cleanup():
_CONFIG_VARS['userbase'] = self.old_user_base
_SCHEMES.set(scheme, 'purelib', self.old_user_site)
os.path.expanduser = self.old_expand
- def _test_user_site(self):
+ self.addCleanup(cleanup)
+
schemes = get_scheme_names()
for key in ('nt_user', 'posix_user', 'os2_home'):
self.assertIn(key, schemes)
dist = Distribution({'name': 'xx'})
cmd = install_dist(dist)
+
# making sure the user option is there
options = [name for name, short, lable in
cmd.user_options]