summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/tests/test_command_install_dist.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/packaging/tests/test_command_install_dist.py')
-rw-r--r--Lib/packaging/tests/test_command_install_dist.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/Lib/packaging/tests/test_command_install_dist.py b/Lib/packaging/tests/test_command_install_dist.py
index 808b568..3345d2e 100644
--- a/Lib/packaging/tests/test_command_install_dist.py
+++ b/Lib/packaging/tests/test_command_install_dist.py
@@ -1,6 +1,7 @@
"""Tests for packaging.command.install."""
import os
+import imp
import sys
from sysconfig import (get_scheme_names, get_config_vars,
_SCHEMES, get_config_var, get_path)
@@ -92,21 +93,20 @@ class InstallTestCase(support.TempdirManager,
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]
@@ -181,9 +181,11 @@ class InstallTestCase(support.TempdirManager,
def test_old_record(self):
# test pre-PEP 376 --record option (outside dist-info dir)
install_dir = self.mkdtemp()
- project_dir, dist = self.create_dist(scripts=['hello'])
+ project_dir, dist = self.create_dist(py_modules=['hello'],
+ scripts=['sayhi'])
os.chdir(project_dir)
- self.write_file('hello', "print('o hai')")
+ self.write_file('hello.py', "def main(): print('o hai')")
+ self.write_file('sayhi', 'from hello import main; main()')
cmd = install_dist(dist)
dist.command_obj['install_dist'] = cmd
@@ -196,8 +198,9 @@ class InstallTestCase(support.TempdirManager,
content = f.read()
found = [os.path.basename(line) for line in content.splitlines()]
- expected = ['hello', 'METADATA', 'INSTALLER', 'REQUESTED', 'RECORD']
- self.assertEqual(found, expected)
+ expected = ['hello.py', 'hello.%s.pyc' % imp.get_tag(), 'sayhi',
+ 'METADATA', 'INSTALLER', 'REQUESTED', 'RECORD']
+ self.assertEqual(sorted(found), sorted(expected))
# XXX test that fancy_getopt is okay with options named
# record and no-record but unrelated