def test_player_classmethod_get_player_url_success(self): assert (Player("Nathan Brown")._get_player_url() == "https://afltables.com/afl/stats/players/N/Nathan_Brown0.html") assert (Player("Nick Riewoldt")._get_player_url() == "https://afltables.com/afl/stats/players/N/Nick_Riewoldt.html") assert (Player("Tony Lockett")._get_player_url() == "https://afltables.com/afl/stats/players/T/Tony_Lockett.html")
def _get_players(self): """ Returns a list of pyAFL.Player objects for all players contained in `self.all_time_players_url` Returns ---------- players : list list of pyAFL.Player objects """ resp = requests.get(self.all_time_players_url) soup = BeautifulSoup(resp.text, "html.parser") player_table = soup.find("table") player_table_body = player_table.find("tbody") player_anchor_tags = player_table_body.findAll("a") players = [ Player(player.text, url=player.attrs.get("href")) for player in player_anchor_tags ] return players
def test_player_name_none_throws_exception(self): with pytest.raises(TypeError): Player()
def test_player_classmethod_get_player_stats(self): player = Player("Nick Riewoldt") assert isinstance(player.get_player_stats(), PlayerStats)
def test_player_classmethod_get_player_url_failure(self): with pytest.raises(LookupError) as e: Player("Babe Ruth")._get_player_url() assert "Found no players with name" in str(e)