summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests/test_dist.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils/tests/test_dist.py')
-rw-r--r--Lib/distutils/tests/test_dist.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py
index 91acf45..81459ac 100644
--- a/Lib/distutils/tests/test_dist.py
+++ b/Lib/distutils/tests/test_dist.py
@@ -55,6 +55,7 @@ class DistributionTestCase(unittest.TestCase):
self.assertEqual(d.get_command_packages(), ["distutils.command"])
def test_command_packages_cmdline(self):
+ from distutils.tests.test_dist import test_dist
sys.argv.extend(["--command-packages",
"foo.bar,distutils.tests",
"test_dist",
@@ -179,9 +180,54 @@ class MetadataTestCase(unittest.TestCase):
dist.metadata.write_pkg_file(sio)
return sio.getvalue()
+ def test_custom_pydistutils(self):
+ # fixes #2166
+ # make sure pydistutils.cfg is found
+ old = {}
+ for env in ('HOME', 'HOMEPATH', 'HOMEDRIVE'):
+ value = os.environ.get(env)
+ old[env] = value
+ if value is not None:
+ del os.environ[env]
+
+ if os.name == 'posix':
+ user_filename = ".pydistutils.cfg"
+ else:
+ user_filename = "pydistutils.cfg"
+
+ curdir = os.path.dirname(__file__)
+ user_filename = os.path.join(curdir, user_filename)
+ f = open(user_filename, 'w')
+ f.write('.')
+ f.close()
+
+ try:
+ dist = distutils.dist.Distribution()
+
+ # linux-style
+ if sys.platform in ('linux', 'darwin'):
+ os.environ['HOME'] = curdir
+ files = dist.find_config_files()
+ self.assert_(user_filename in files)
+
+ # win32-style
+ if sys.platform == 'win32':
+ # home drive should be found
+ os.environ['HOMEPATH'] = curdir
+ files = dist.find_config_files()
+ self.assert_(user_filename in files)
+ finally:
+ for key, value in old.items():
+ if value is None:
+ continue
+ os.environ[key] = value
+ os.remove(user_filename)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(DistributionTestCase))
suite.addTest(unittest.makeSuite(MetadataTestCase))
return suite
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")