test_fanmatch failing
Closed this issue · 1 comments
FAILED tests/test_fanmatch.py::test_fanmatch - AttributeError: 'DataFrame' object has no attribute 'ThrillScore'
Seems like some of the parsing got borked due to some small updates in the source HTML for the FanMatch page which inserted some whitespaces; likely needs a few rather simple fixes to get it back on track:
> fm_df
Game ... Excite ment
0 30 Texas Tech 89, 6 West Virginia 81 [75] MVP:... ... 1.77
1 31 Marquette 84, 59 Xavier 82 (2OT) [79] MVP: ... ... 2.94
2 33 LSU 90, 44 Alabama 76 [76] MVP: Emmitt Will... ... 0.63
3 4 Baylor 67, 63 Iowa St. 53 [64] MVP: Freddie ... ... 0.09
4 22 Penn St. 64, 38 Indiana 49 [70] MVP: Lamar ... ... 1.16
.. ... ... ...
56 3. Maceo Jack, George Washington • 35 pts (5-6... ... 3. Maceo Jack, George Washington • 35 pts (5-6...
57 Note: Rankings shown for each team are for the... ... Note: Rankings shown for each team are for the...
58 Mean absolute error of predicted margin of vic... ... Mean absolute error of predicted margin of vic...
59 Mean absolute error of predicted total score t... ... Mean absolute error of predicted total score t...
60 Today's stats (D-I vs D-I only): Points per ga... ... Today's stats (D-I vs D-I only): Points per ga...
[61 rows x 7 columns]
> fm_df.columns
Index(['Game', 'Prediction', 'Time (ET)', 'Location', 'Thrill Score',
'Come back', 'Excite ment'],
dtype='object')
Re-naming the columns seems to get us most of the way there; test is still failing my fork's branch as it seems the test case's values have some inadvertent whitespace inserted now:
E AssertionError: assert ['31 Marquette 84, 59 Xavier 82 (2OT)',\n 'Cincinnati, OH Cintas Center',\n '68.2',\n '8',\n '2.94',\n ' 2',\n 'nan',\n 'nan',\n 'Sacar Anim (28p/5r/2a/1b/4s)',\n '79',\n 'Marquette',\n '73-72',\n '51%',\n '1',\n 'Xavier',\n '2OT',\n 'Xavier',\n '59',\n '82',\n 'Marquette',\n '31',\n '84',\n '2'] == ['31 Marquette 84, 59 Xavier 82 (2OT)',\n 'Cincinnati, OH Cintas Center',\n '68.2',\n '8',\n '2.94',\n '2',\n 'nan',\n 'nan',\n 'Sacar Anim (28p/5r/2a/1b/4s)',\n '79',\n 'Marquette',\n '73-72',\n '51%',\n '1',\n 'Xavier',\n '2OT',\n 'Xavier',\n '59',\n '82',\n 'Marquette',\n '31',\n '84',\n '2']
E At index 5 diff: ' 2' != '2'
E Full diff:
E [
E '31 Marquette 84, 59 Xavier 82 (2OT)',
E 'Cincinnati, OH Cintas Center',
E '68.2',
E '8',
E '2.94',
E - '2',
E + ' 2',
E ? +
E 'nan',
E 'nan',
E 'Sacar Anim (28p/5r/2a/1b/4s)',
E '79',
E 'Marquette',
E '73-72',
E '51%',
E '1',
E 'Xavier',
E '2OT',
E 'Xavier',
E '59',
E '82',
E 'Marquette',
E '31',
E '84',
E '2',
E ]
tests/test_fanmatch.py:34: AssertionError
_______________________________________________________________ test_get_program_ratings _______________________________________________________________
browser = <mechanicalsoup.stateful_browser.StatefulBrowser object at 0x1241b6160>
def test_get_program_ratings(browser):
expected = (357, 17)
df = kpmisc.get_program_ratings(browser)
> assert df.shape == expected
E assert (358, 17) == (357, 17)
E At index 0 diff: 358 != 357
E Full diff:
E - (357, 17)
E ? ^
E + (358, 17)
E ? ^
tests/test_misc.py:76: AssertionError
This could also be very well a slight difference in the way different versions of pandas
parse the incoming HTML. To preserve compatibility if indeed that's the case, it's a simple strip()
of whitespace here (as opposed to adjusting the index on which the slicing happens):
Line 58 in 36e2ab8
PR to follow.