File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+
3+ import pytest
4+
5+ DEFAULT_TEST_DATASET_URL = (
6+ "hf://policyengine/policyengine-uk-data-private/enhanced_frs_2023_24.h5@1.40.3"
7+ )
8+
9+ if os .environ .get ("HUGGING_FACE_TOKEN" ) and not os .environ .get (
10+ "POLICYENGINE_UK_DEFAULT_DATASET"
11+ ):
12+ os .environ ["POLICYENGINE_UK_DEFAULT_DATASET" ] = DEFAULT_TEST_DATASET_URL
13+
14+
15+ def pytest_collection_modifyitems (config , items ):
16+ has_default_dataset = bool (os .environ .get ("POLICYENGINE_UK_DEFAULT_DATASET" ))
17+ if has_default_dataset :
18+ return
19+
20+ skip_microsimulation = pytest .mark .skip (
21+ reason = (
22+ "Requires POLICYENGINE_UK_DEFAULT_DATASET or HUGGING_FACE_TOKEN "
23+ "for microsimulation dataset access"
24+ )
25+ )
26+ for item in items :
27+ if "microsimulation" in item .keywords :
28+ item .add_marker (skip_microsimulation )
Original file line number Diff line number Diff line change 1616from policyengine_uk import Microsimulation
1717from policyengine_uk .model_api import Scenario
1818
19- # Check if HF token is available for data-dependent tests
20- HF_TOKEN_AVAILABLE = bool (os .environ .get ("HUGGING_FACE_TOKEN" ))
19+ # Check if a default dataset is available for data-dependent tests
20+ HF_TOKEN_AVAILABLE = bool (
21+ os .environ .get ("HUGGING_FACE_TOKEN" )
22+ or os .environ .get ("POLICYENGINE_UK_DEFAULT_DATASET" )
23+ )
2124requires_hf_data = pytest .mark .skipif (
2225 not HF_TOKEN_AVAILABLE ,
2326 reason = "Requires HUGGING_FACE_TOKEN for private data access" ,
You can’t perform that action at this time.
0 commit comments