Mock/Monkeypatch BeautifulSoup html objects for Pytest

In your test file, you could try like this:

from module.script import get_player_stats_data


@pytest.fixture(scope="session")
def urlopen(mocker):
    with open(fname, "rb") as fp:
        html = fp.read()
    urlopen = mocker.patch("module.script.urlopen")
    urlopen.return_value = html
    return urlopen


def test_raw_stats_rows(urlopen):
    df = get_player_stats_data()
    assert len(df) == 30


def test_raw_stats_schema(urlopen):
    df = get_player_stats_data()
    assert list(df.columns) == raw_stats_cols