[Python-Dev] changing regrtest to handle import errors

Jeff Balogh its.jeff.balogh at gmail.com
Wed Mar 19 05:45:37 CET 2008


Neal Norwitz wrote:
> [changing to: and subject: ]
> 
> On Tue, Mar 18, 2008 at 4:09 PM, Guido van Rossum <guido at python.org> wrote:
> > On Tue, Mar 18, 2008 at 3:58 PM, neal.norwitz
> >  <python-3000-checkins at python.org> wrote:
> >  >  Get this test to pass (UserList/UserDict no longer exist and caused a skip).
> >
> >  I think the automatic skip on ImportError is harmful.
> >
> >  We should add a helper function to test_support so that you can write
> >
> >  foobar = test_support.import_optional('foobar')
> >
> >  and it will skip the test if foobar cannot be imported; all other
> >  failing imports should cause the test to *fail*.
> >
> >  Any takers? This should be an easy two-part task.
> 
> This would be a great starter project for a new developer.
> http://bugs.python.org/issue2409
> Let me know if you could use some help.  Feel free to contact me on or off list.
> 
> n

This is available in the form of four patches on
http://bugs.python.org/issue2409.  

The first adds test_support.optional_import, which I now see is the opposite of
Guido's suggestion (blame the dyslexia).  I actually prefer optional_import,
though, since it puts 'import' next to the imported name, but I can add a fix if
it's a problem.

The next two patches refactor the imports of test_{sunaudiodev,winreg}.py to
make the imports easier to work with in the new scheme.

The last patch fixes the stdlib tests to use optional_import at the spots where
I was getting ImportErrors on my box (x86 Linux).

Please test these on your boxes so we can discover all the ImportErrors before
the buildbots do.

Thanks,
Jeff Balogh


More information about the Python-Dev mailing list