diff options
author | Andrew Kuchling <amk@amk.ca> | 2013-11-10 23:11:00 (GMT) |
---|---|---|
committer | Andrew Kuchling <amk@amk.ca> | 2013-11-10 23:11:00 (GMT) |
commit | 2a1838b9dfa6f825ee272ec8bef683394e845830 (patch) | |
tree | 38443cd0914b1b8a763fcf7ce111f48cb7c1bf7b /Lib/distutils/tests/test_dist.py | |
parent | ce4179d0226768988965ac238ad15791cd377def (diff) | |
download | cpython-2a1838b9dfa6f825ee272ec8bef683394e845830.zip cpython-2a1838b9dfa6f825ee272ec8bef683394e845830.tar.gz cpython-2a1838b9dfa6f825ee272ec8bef683394e845830.tar.bz2 |
Issue #19544 and Issue #1180: Restore global option to ignore ~/.pydistutils.cfg in Distutils, accidentally removed in backout of distutils2 changes.
Diffstat (limited to 'Lib/distutils/tests/test_dist.py')
-rw-r--r-- | Lib/distutils/tests/test_dist.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py index 9a8ca19..102c553 100644 --- a/Lib/distutils/tests/test_dist.py +++ b/Lib/distutils/tests/test_dist.py @@ -39,6 +39,7 @@ class TestDistribution(Distribution): class DistributionTestCase(support.LoggingSilencer, + support.TempdirManager, support.EnvironGuard, unittest.TestCase): @@ -213,6 +214,34 @@ class DistributionTestCase(support.LoggingSilencer, self.assertRaises(ValueError, dist.announce, args, kwargs) + def test_find_config_files_disable(self): + # Ticket #1180: Allow user to disable their home config file. + temp_home = self.mkdtemp() + if os.name == 'posix': + user_filename = os.path.join(temp_home, ".pydistutils.cfg") + else: + user_filename = os.path.join(temp_home, "pydistutils.cfg") + + with open(user_filename, 'w') as f: + f.write('[distutils]\n') + + def _expander(path): + return temp_home + + old_expander = os.path.expanduser + os.path.expanduser = _expander + try: + d = Distribution() + all_files = d.find_config_files() + + d = Distribution(attrs={'script_args': ['--no-user-cfg']}) + files = d.find_config_files() + finally: + os.path.expanduser = old_expander + + # make sure --no-user-cfg disables the user cfg file + self.assertEquals(len(all_files)-1, len(files)) + class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): |