pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.67k stars 17.91k forks source link

TST: wb test failing #8768

Closed jreback closed 9 years ago

jreback commented 9 years ago

xref #8551

cc @jnmclarty

.SS.E
======================================================================
ERROR: test_wdi_search (pandas.io.tests.test_wb.TestWB)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jreback/pandas/pandas/util/testing.py", line 1417, in wrapper
    return t(*args, **kwargs)
  File "/Users/jreback/pandas/pandas/io/tests/test_wb.py", line 25, in test_wdi_search
    result = search('gdp.*capita.*constant').loc[6716:,['id','name']]
  File "/Users/jreback/pandas/pandas/core/indexing.py", line 1200, in __getitem__
    return self._getitem_tuple(key)
  File "/Users/jreback/pandas/pandas/core/indexing.py", line 704, in _getitem_tuple
    self._has_valid_tuple(tup)
  File "/Users/jreback/pandas/pandas/core/indexing.py", line 131, in _has_valid_tuple
    if not self._has_valid_type(k, i):
  File "/Users/jreback/pandas/pandas/core/indexing.py", line 1260, in _has_valid_type
    (key.start, self.obj._get_axis_name(axis))
KeyError: 'start bound [6716] is not the [index]'

----------------------------------------------------------------------
Ran 5 tests in 14.969s
jnmclarty commented 9 years ago

Looking at this now.

jnmclarty commented 9 years ago

The problem is that world bank's search results are not static.

it's now returning...

                      id                                               name
700   6.0.GDPpc_constant  GDP per capita, PPP (constant 2011 internation...
4682             GDPPCKD             GDP per Capita, constant US$, millions
6717      NY.GDP.PCAP.KD                 GDP per capita (constant 2005 US$)
6719      NY.GDP.PCAP.KN                      GDP per capita (constant LCU)
6721   NY.GDP.PCAP.PP.KD  GDP per capita, PPP (constant 2011 internation...

...so the test fails.

It's a poorly designed test. FWIW, I updated the test in my last commit, but wasn't the original creator/designer of it.

A reasonable check, would be to make sure the contents of the 'name' column contain, say, at least 1 element with 'GDP' in it. I'll can do a PR momentarily.

jreback commented 9 years ago

maybe just assert that u can at least 1 row back

jnmclarty commented 9 years ago

Already had this done, before I saw your comment.

jnmclarty commented 9 years ago

I'm crashing for the night. That's ready to be merged, and is actually an improved test - and in fewer lines!

jreback commented 9 years ago

closed by #8769