Skip to content

Commit

Permalink
Fix issue pulling future NFL boxscores
Browse files Browse the repository at this point in the history
For NFL games that are scheduled but have not yet taken place, the code
would take the preview link for the game and treat it as the Boxscore
link, causing errors to be thrown while attempt to pull Boxscore data
from the preview which doesn't have the intended information.

Signed-Off-By: Robert Clark <robdclark@outlook.com>
  • Loading branch information
roclark committed Nov 13, 2020
1 parent 9b6039f commit 7c6d18f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sportsreference/nfl/boxscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ def _alt_abbreviations(self, boxscore):
for column in game_info('th').items():
if column.text():
abbreviations.append(column.text())
if not abbreviations:
return None, None
return abbreviations

def _parse_game_data(self, uri):
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_nfl_boxscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ def test_finding_away_team_with_no_abbrs(self):

assert team == AWAY

def test_missing_abbreviations(self):
table = '<table id="team_stats"><thead></thead></table>'
output = self.boxscore._alt_abbreviations(pq(table))

assert output == (None, None)


class TestNFLBoxscores:
@patch('requests.get', side_effect=mock_pyquery)
Expand Down

0 comments on commit 7c6d18f

Please sign in to comment.