diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py index cf254ac1c43..2bd2292e8cc 100644 --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -249,12 +249,18 @@ class BuildExtTestCase(support.TempdirManager, # issue #5977 : distutils build_ext.get_outputs # returns wrong result with --inplace - cmd.inplace = 1 - cmd.run() - so_file = cmd.get_outputs()[0] + other_tmp_dir = os.path.realpath(self.mkdtemp()) + old_wd = os.getcwd() + os.chdir(other_tmp_dir) + try: + cmd.inplace = 1 + cmd.run() + so_file = cmd.get_outputs()[0] + finally: + os.chdir(old_wd) self.assert_(os.path.exists(so_file)) so_dir = os.path.dirname(so_file) - self.assertEquals(so_dir, os.getcwd()) + self.assertEquals(so_dir, other_tmp_dir) cmd.inplace = 0 cmd.run() diff --git a/Misc/NEWS b/Misc/NEWS index 373405b9d5d..8107977d225 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -194,6 +194,9 @@ Core and Builtins Library ------- +- Issue #6022: a test file was created in the current working directory by + test_get_outputs in Distutils. + - Issue #5977: distutils build_ext.get_outputs was not taking into account the inplace option. Initial patch by kxroberto.