[issue17689] Fix test discovery for test_tarfile.py

2013-06-15 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
stage:  - committed/rejected

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17689] Fix test discovery for test_tarfile.py

2013-06-15 Thread Zachary Ware

Zachary Ware added the comment:

Superseded by issue18223.

--
resolution:  - duplicate
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17689] Fix test discovery for test_tarfile.py

2013-04-16 Thread Ezio Melotti

Ezio Melotti added the comment:

 I found requires_bz2 and requires_lzma that already exist;

There's also requires_zlib.  import_module is also somewhat similar, but it's 
used to skip the whole test file when the module is missing.

 Here's another thought; would it be more useful to have a general
 version of this skip decorator in test.support

We were discussing this a couple of days ago on #python-dev.  Adding a 
skip_unless_module('modulename') (or requires_module('modulename')) and get rid 
of the several requires_* is certainly an option.

skip_unless_* (or requires_*) is shorter and more readable than 
skip_unless_module('modulename'), so this would be my preferred choice if it's 
defined and used within a single test module.  However if we add something to 
test.support, I'd rather have a more generic skip_unless_module('modulename') 
and get rid of the requires_*.
It's should also be possible to define specific ``skip_unless_x = 
skip_unless_module('x')`` in the test modules if necessary.

 should I just add a requires_gzip to test.support and use those three
 in test_tarfile?

I think that's reasonable for now -- we can always refactor it later and 
replace them with a skip_unless_module()

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17689] Fix test discovery for test_tarfile.py

2013-04-16 Thread Zachary Ware

Zachary Ware added the comment:

 should I just add a requires_gzip to test.support and use those three
 in test_tarfile?

 I think that's reasonable for now -- we can always refactor it later 
 and replace them with a skip_unless_module()

Here's a patch :)

--
Added file: http://bugs.python.org/file29885/test_tarfile_discovery.v3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17689] Fix test discovery for test_tarfile.py

2013-04-15 Thread Zachary Ware

Zachary Ware added the comment:

That is indeed simpler than what I wrote, and it does work as expected.  But, 
is it preferable to do it this way, or with Ezio's suggested method 
(``skip_unless_gzip = unittest.skipUnless(gzip, gzip not available)``, and 
for bz2 and lzma)?  I can see merits to both; mine only requires a docstring 
change if there's a new compression module sometime in the future, but Ezio's 
is simpler and shorter.

Here's another thought; would it be more useful to have a general version of 
this skip decorator in test.support, something along the lines of:


def skipWithoutModule(name):

Skip if the named module is not available.

try:
module = importlib.import_module(name)
except ImportError:
module = None

return unittest.skipUnless(module, 
   {} module not available.format(name))


And, actually, looking through test.support to see if there was anything like 
this already, I found requires_bz2 and requires_lzma that already exist; should 
I just add a requires_gzip to test.support and use those three in test_tarfile?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17689] Fix test discovery for test_tarfile.py

2013-04-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Wouldn't it be simpler to write (untested):

def skipUnlessCompressionModule(name):

Skip if the specified compression module is not available.  Must e a
string, currently any of 'gzip', 'bz2', or 'lzma'.

return unittest.skipUnless(globals()[name],
   '{} not available'.format(name))

?

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17689] Fix test discovery for test_tarfile.py

2013-04-11 Thread Zachary Ware

Changes by Zachary Ware zachary.w...@gmail.com:


Added file: http://bugs.python.org/file29779/test_tarfile_discovery.v2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17689] Fix test discovery for test_tarfile.py

2013-04-10 Thread Zachary Ware

New submission from Zachary Ware:

Here's a patch for test_tarfile.py discovery.

There are a couple of inheritance issues resolved; CommonReadTest (and its 
children, MiscReadTest and StreamReadTest) are changed simply to avoid running 
the tests in CommonReadTest on their own--they pass, but are unnecessary.  
LongnameTest and WriteTestBase cause failures when run on their own, so they no 
longer inherit from unittest.TestCase.

test_main() has been replaced by setUpModule, some skip decorators, and 
tearDownModule.  HardlinkTest and LinkEmulationTest are given skipUnless and 
skipIf decorators, respectively, instead of simply being appended to 'tests' or 
not.  This does change the test count; on my machine it adds the 4 tests 
skipped in LinkEmulationTest, raising the total from 307 to 311.  gzip, bz2, 
and lzma setup has been moved into setUpModule, and each group of those tests 
now has a new dummy base class with a skip decorator.  This will also change 
test counts on machines that don't have gzip, bz2, or lzma available.  
tearDownModule replaces the finally clause at the end of test_main().

A simpler patch would just convert test_main into load_tests and add a 
tearDownModule function to replace the finally clause of test_main(), but I 
believe this slightly more invasive approach is more correct and should 
simplify future maintenance of the module.

Thanks,

Zach

--
components: Tests
files: test_tarfile_discovery.diff
keywords: patch
messages: 186525
nosy: brett.cannon, ezio.melotti, zach.ware
priority: normal
severity: normal
status: open
title: Fix test discovery for test_tarfile.py
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file29765/test_tarfile_discovery.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com