Changes by Ezio Melotti ezio.melo...@gmail.com:
--
nosy: +cjerdonek
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7712
___
___
Python-bugs-list
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
É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
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
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,
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__
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
___
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
___
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
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
___
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
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
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
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
--
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
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
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
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).
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
___
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
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
___
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
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
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,
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:
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
___
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
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
___
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
___
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
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
___
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
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
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
___
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
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
___
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
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.
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
Changes by Florent Xicluna la...@yahoo.fr:
--
keywords: -needs review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7712
___
___
Python-bugs-list
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
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
42 matches
Mail list logo