NBA-Search icon indicating copy to clipboard operation
NBA-Search copied to clipboard

test_get_adv_stats is failing from NoneType object

Open skekre98 opened this issue 4 years ago • 6 comments

Describe the bug test_get_adv_stats is failing, seems to be from a missing div when scraping advanced stats.

To Reproduce Steps to reproduce the behavior:

  1. Setup the environment with ./setup.sh
  2. Run python main.py test to run unit tests
  3. See error
ERROR: test_get_adv_stats (tests.module_tests.TestScraper)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/circleci/project/tests/module_tests.py", line 107, in test_get_adv_stats
    stat = scraper.get_adv_stat(random_name, random_stat)
  File "/home/circleci/project/modules/scraper.py", line 288, in get_adv_stat
    comments = advanced_div.find_all(string=lambda text: isinstance(text, Comment))[0]
AttributeError: 'NoneType' object has no attribute 'find_all'

Expected behavior This should correctly scrape the advanced of NBA players and check for any NoneType objects in case there is an error in scraping or something is removed in the future.

Desktop (please complete the following information):

  • OS: n/a
  • Browser: n/a
  • Version: n/a

Additional context This is setup agnostic the issue was found during CircleCI tests.

skekre98 avatar Aug 30 '21 18:08 skekre98

You can assign this issue to me. I'll review it in the next couple of days.

AColocho avatar Aug 31 '21 01:08 AColocho

Awesome, thanks @AColocho

skekre98 avatar Aug 31 '21 21:08 skekre98

@skekre98 I found the issue. Basketball Reference removed the comment that was used as an anchor to find the table. I'm having trouble understand what the function returns. Is it just the latest stat as a float? or is it all the available stats for the category as a list of floats?

AColocho avatar Aug 31 '21 22:08 AColocho

Hi @AColocho, the function should be returning the advanced statistic as a float value. The user will specify the name of the player and the advanced statistic to retrieve when calling the function. For example:

stat = scraper.get_adv_stat("Kobe Bryant", "defensive box plus/minus")

skekre98 avatar Sep 01 '21 17:09 skekre98

is this issue done or not, i would like to do on it

dominikk12 avatar Oct 04 '21 08:10 dominikk12

Issue is done. It's waiting code review and merge.

AColocho avatar Oct 04 '21 23:10 AColocho