mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
Cleanups in distutils tests.
- Actually check the contents of the file created by bdist_dumb. - Don’t use “RECORD” as filename for non-PEP 376 record file - Don’t start method name with “_test”, it smells like a disabled test method instead of an helper method - Fix some idioms (assertIn, addCleanup)
This commit is contained in:
parent
91d5193b3a
commit
af2ffd75cf
3 changed files with 32 additions and 25 deletions
|
|
@ -87,19 +87,17 @@ 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():
|
||||
site.USER_BASE = self.old_user_base
|
||||
site.USER_SITE = self.old_user_site
|
||||
install_module.USER_BASE = self.old_user_base
|
||||
install_module.USER_SITE = self.old_user_site
|
||||
os.path.expanduser = self.old_expand
|
||||
|
||||
def _test_user_site(self):
|
||||
self.addCleanup(cleanup)
|
||||
|
||||
for key in ('nt_user', 'unix_user', 'os2_home'):
|
||||
self.assertTrue(key in INSTALL_SCHEMES)
|
||||
self.assertIn(key, INSTALL_SCHEMES)
|
||||
|
||||
dist = Distribution({'name': 'xx'})
|
||||
cmd = install(dist)
|
||||
|
|
@ -107,14 +105,14 @@ class InstallTestCase(support.TempdirManager,
|
|||
# making sure the user option is there
|
||||
options = [name for name, short, lable in
|
||||
cmd.user_options]
|
||||
self.assertTrue('user' in options)
|
||||
self.assertIn('user', options)
|
||||
|
||||
# setting a value
|
||||
cmd.user = 1
|
||||
|
||||
# user base and site shouldn't be created yet
|
||||
self.assertTrue(not os.path.exists(self.user_base))
|
||||
self.assertTrue(not os.path.exists(self.user_site))
|
||||
self.assertFalse(os.path.exists(self.user_base))
|
||||
self.assertFalse(os.path.exists(self.user_site))
|
||||
|
||||
# let's run finalize
|
||||
cmd.ensure_finalized()
|
||||
|
|
@ -123,8 +121,8 @@ class InstallTestCase(support.TempdirManager,
|
|||
self.assertTrue(os.path.exists(self.user_base))
|
||||
self.assertTrue(os.path.exists(self.user_site))
|
||||
|
||||
self.assertTrue('userbase' in cmd.config_vars)
|
||||
self.assertTrue('usersite' in cmd.config_vars)
|
||||
self.assertIn('userbase', cmd.config_vars)
|
||||
self.assertIn('usersite', cmd.config_vars)
|
||||
|
||||
def test_handle_extra_path(self):
|
||||
dist = Distribution({'name': 'xx', 'extra_path': 'path,dirs'})
|
||||
|
|
@ -178,14 +176,13 @@ class InstallTestCase(support.TempdirManager,
|
|||
def test_record(self):
|
||||
install_dir = self.mkdtemp()
|
||||
project_dir, dist = self.create_dist(scripts=['hello'])
|
||||
self.addCleanup(os.chdir, os.getcwd())
|
||||
os.chdir(project_dir)
|
||||
self.write_file('hello', "print('o hai')")
|
||||
|
||||
cmd = install(dist)
|
||||
dist.command_obj['install'] = cmd
|
||||
cmd.root = install_dir
|
||||
cmd.record = os.path.join(project_dir, 'RECORD')
|
||||
cmd.record = os.path.join(project_dir, 'filelist')
|
||||
cmd.ensure_finalized()
|
||||
cmd.run()
|
||||
|
||||
|
|
@ -204,7 +201,6 @@ class InstallTestCase(support.TempdirManager,
|
|||
install_dir = self.mkdtemp()
|
||||
project_dir, dist = self.create_dist(ext_modules=[
|
||||
Extension('xx', ['xxmodule.c'])])
|
||||
self.addCleanup(os.chdir, os.getcwd())
|
||||
os.chdir(project_dir)
|
||||
support.copy_xxmodule_c(project_dir)
|
||||
|
||||
|
|
@ -216,7 +212,7 @@ class InstallTestCase(support.TempdirManager,
|
|||
dist.command_obj['install'] = cmd
|
||||
dist.command_obj['build_ext'] = buildextcmd
|
||||
cmd.root = install_dir
|
||||
cmd.record = os.path.join(project_dir, 'RECORD')
|
||||
cmd.record = os.path.join(project_dir, 'filelist')
|
||||
cmd.ensure_finalized()
|
||||
cmd.run()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue