[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +cjerdonek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Ezio Melotti ezio.melo...@gmail.com added the comment: The cleanups have been committed in r78719 (trunk) and r78723 (py3k). -- resolution: - accepted stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Éric Araujo mer...@netwok.org added the comment: Hello One advice against using __file__: http://lists.debian.org/debian-python/2010/01/msg00172.html Regards -- nosy: +merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Ezio Melotti ezio.melo...@gmail.com added the comment: Ported to py3k in r78214. I will think about the cleanups later, they are not so important right now. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: Complex is better than complicated... Special cases aren't special enough to break the rules. The module regrtest is complex enough. We don't need to keep useless hacks inside. It would be more interesting to replace the hack with some words, or an assertion, and understand the real (or hypothetic) issue behind this hack. Eventually, if we keep these hacks around, it may hide real bugs. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: Fixed on trunk with r78136. Before closing this issue, we may apply additional cleanup on regrtest: - the sys.path hack is not needed anymore (no risk of relative imports) - the hack for sys.argv[0] could be removed too, and use __file__ instead -- Added file: http://bugs.python.org/file16218/issue7712_regrtest_remove_hacks.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file16218/issue7712_regrtest_remove_hacks.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: Added file: http://bugs.python.org/file16219/issue7712_regrtest_rm_hacks.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Ezio Melotti ezio.melo...@gmail.com added the comment: I'm not sure it's safe to remove those hacks, they might be necessary in some corner case. I'll also port this to py3k before closing the issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file16167/issue7712_context_manager_v5.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Brian Curtin cur...@acm.org added the comment: With Ezio's latest patch (sent via IRC), test_bufio still fails and additionally test_mailbox fails. If I apply the patch on #7443 along with Ezio's patch, everything looks fine. I haven't thoroughly looked at that issue, but on the surface it looks similar (same setup, same result). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Ezio Melotti ezio.melo...@gmail.com added the comment: Final version of the patch, with the temp_cwd context manager added to test_support and used in test_regrtest to run the test suite in a temporary directory. It also includes a fix for test_subprocess that was failing when the tests are not run in the original cwd. -- Added file: http://bugs.python.org/file16179/issue7712v3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Brian Curtin cur...@acm.org added the comment: With the latest patch I get one failure: test_bufio. I piped that test to a file and attached the results here. There are numerous Permission denied: @test IOErrors. -- Added file: http://bugs.python.org/file16181/test_bufio.stdout.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: Brian, is it the only one failing? Did you have some test running before? Which one? (alphabetic order?) Do you reproduce the error when running this test alone? -m test.regrtest -uall test_bufio -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Brian Curtin cur...@acm.org added the comment: Yep, that's the only one failing. The output I attached is the result of running the test alone. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: Ok, it may be not related directly with this patch. Can you diagnose if it something like #7443? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: And you could try the patch attached to #7443, and see if it fixes the test_bufio issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: The command line used to run the tests is important. If you run through test.regrtest, it should chdir to a sandbox directory to run the test. If you call directly the test_bufio.py file, it runs in the current directory (as before the patch). And the permission of the current directory may give a difference in the 2nd case. Variants: python.exe -m test.regrtest test_bufio python.exe Lib/test/regrtest.py test_bufio python.exe Lib/test/test_bufio.py(fail if home directory is RO) And another full run: python.exe -m test.regrtest Try some of these variants, it may help diagnose the windows issue. (Note: maybe some antivirus or other software may be related to the race condition described on #7443) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file16152/issue7712_context_manager_v3a.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: Removed the dummy CM hack. Now it should be ready for final review. -- Added file: http://bugs.python.org/file16165/issue7712_context_manager_v4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file16165/issue7712_context_manager_v4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: Let's fix some other tests. -- Added file: http://bugs.python.org/file16167/issue7712_context_manager_v5.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Ezio Melotti ezio.melo...@gmail.com added the comment: Almost completed patch, the code should be OK, I just have to add a few comments and check that it works fine in all the situations. -- Added file: http://bugs.python.org/file16175/issue7712v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: It looks fine. Few comments: - {}_python_{} could be better, to identify the culprit for leftover directories. - the warning message may be more specific: warnings.warn('tests may fail, unable to switch to ' + name, RuntimeWarning, stacklevel=3) - style guide recommends two spaces after a sentence-ending period -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: Patch which fixes the relative import issue. ~ $ cd Lib/ ~ $ ../python -m test.regrtest Note: There are some 2-spaces indents for patch readability. Change them before commit. -- versions: -Python 2.6, Python 3.1 Added file: http://bugs.python.org/file16150/issue7712_context_manager_v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file15956/issue7712_context_manager.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: Slightly more readable, without 2-spaces indent. -- Added file: http://bugs.python.org/file16151/issue7712_context_manager_v3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file16150/issue7712_context_manager_v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file16151/issue7712_context_manager_v3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Florent Xicluna la...@yahoo.fr added the comment: There were syntax errors in the previous patch. Sorry. -- Added file: http://bugs.python.org/file16152/issue7712_context_manager_v3a.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file15951/temp_cwd_decorator_v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Changes by Florent Xicluna la...@yahoo.fr: -- title: Add a context manager to change cwd in test.test_support - Add a context manager to change cwd in test.test_support and run the test suite in a temp dir. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support and run the test suite in a temp dir.
Ezio Melotti ezio.melo...@gmail.com added the comment: Here is a patch based on the previous patches and some discussion. I still have to test it better and add a few comments, but it should be almost ok. -- Added file: http://bugs.python.org/file16146/issue7712.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Changes by Florent Xicluna la...@yahoo.fr: Removed file: http://bugs.python.org/file15907/temp_cwd_decorator.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Florent Xicluna la...@yahoo.fr added the comment: Changed, after review from Ezio and other developpers. -- Added file: http://bugs.python.org/file15951/temp_cwd_decorator_v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Antoine Pitrou pit...@free.fr added the comment: with_writable_cwd should probably use functools.wraps. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Ezio Melotti ezio.melo...@gmail.com added the comment: The patch looks good, I'd just move _test_cwd inside the function and drop the [:-3] from TESTFN, but apart from that it's OK. I also agree that functools.wraps should be added. To summarize the discussion we had on #python-dev: 1) the context manager should always create a writable cwd and to be able to run with -J it should contain the process id. Using TESTFN as first-level dir solves both the issues; 2) a suffix is added to TESTFN to let the tests use TESTFN as a valid filename; 3) the second-level dir is 'tempcwd' by default or can be passed to the function in case a test needs a specific name for the cwd; The result will be something like '@test__tmp_cwd/dirname'. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Florent Xicluna la...@yahoo.fr added the comment: Different approach, after some other talks with Ezio and David. Now the directory is changed before running any test. The developer can assume that the current directory if always writable. It makes the tests easier to write, and repeatable. Additionally, TESTFN always contains a single filename (without path). Before this change, it could be /tmp/@test or @test, which is error-prone. The decorator becomes useless. -- Added file: http://bugs.python.org/file15956/issue7712_context_manager.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Florent Xicluna la...@yahoo.fr added the comment: A patch which provides a context manager and a decorator. (with ideas from Ezio and Antoine) Sample usages: with temp_cwd() as cwd: assert cwd == os.getcwd() @writablecwd def test_zipfile(): # do something useful print os.path.abspath('.') -- nosy: +pitrou Added file: http://bugs.python.org/file15907/temp_cwd_decorator.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Changes by Florent Xicluna la...@yahoo.fr: -- keywords: -needs review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
Changes by Brian Curtin cur...@acm.org: -- nosy: +brian.curtin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7712] Add a context manager to change cwd in test.test_support
New submission from Ezio Melotti ezio.melo...@gmail.com: To simplify the tests that require a different CWD I wrote a context manager that allows to change the working directory. I used it on #3426 to test os.path.abspath() with ASCII and non-ASCII CWDs and realized that it can also be used to fix #5684 where a zipfile fails to extract the content of the archive in the CWD if it is read-only. Patch attached. -- assignee: ezio.melotti components: Tests files: tempcwd.patch keywords: needs review, patch, patch messages: 97865 nosy: ezio.melotti, flox priority: normal severity: normal stage: patch review status: open title: Add a context manager to change cwd in test.test_support type: feature request versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2 Added file: http://bugs.python.org/file15904/tempcwd.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7712 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com