Fix nose test generator bug. Better error messages · pandas-dev/pandas@9977da2 (original) (raw)

Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
7 7
8 8 import os
9 9 import nose
10 +import functools
10 11
11 12 import pandas.util.testing as tm
12 13 from pandas import DataFrame
@@ -31,12 +32,18 @@ def __init__(self):
31 32
32 33 def test_compressed_urls(self):
33 34 """Test reading compressed tables from URL."""
35 +# test_fxn is a workaround for more descriptive nose reporting.
36 +# See http://stackoverflow.com/a/37393684/4651668.
37 +test_fxn = functools.partial(self.check_table)
38 +
34 39 for compression, extension in self.compression_to_extension.items():
35 40 url = self.base_url + extension
36 -yield self.check_table, url, compression
37 -yield self.check_table, url, 'infer'
41 +# args is a (compression, engine) tuple
42 +for args in [(compression, 'python'), ('infer', 'python')]:
43 +test_fxn.description = '{} compression, {} engine'.format(*args)
44 +yield (test_fxn, url) + args
38 45
39 -def check_table(url, compression, engine='python'):
46 +def check_table(self, url, compression, engine):
40 47 url_table = read_table(url, compression=compression, engine=engine)
41 48 tm.assert_frame_equal(url_table, self.local_table)
42 49