ZipLime's picture
Update the Commitments of Traders dataset
9770079 verified
Raw History Blame Contribute Delete
1.08 kB
"""Fixtures: the CFTC's own pages, and a slice of each annual archive.
The two HTML pages are stored whole, because they are what the release instants
are read from and every one of their quirks matters. The archives are stored as
a slice -- fourteen markets and every week of them -- since a full year is eight
megabytes and the parser does not care how many markets are in the file.
The three archives are chosen for what is different about them: the legacy
report spells its columns one way and the disaggregated another, and the 2010
file dates its rows `12/31/2010` where every later file writes `2010-12-31`.
"""
from __future__ import annotations
import gzip
from pathlib import Path
import pytest
FIXTURES = Path(__file__).parent / "fixtures"
def load_page(name: str) -> str:
return gzip.decompress((FIXTURES / "schedule" / name).read_bytes()).decode("utf-8")
def load_archive(name: str) -> bytes:
return (FIXTURES / "archives" / name).read_bytes()
@pytest.fixture
def page():
return load_page
@pytest.fixture
def archive():
return load_archive