cterdam commited on
Commit
6e41cfc
·
verified ·
1 Parent(s): 40b40a6

Update test to load from HF Hub

Browse files
Files changed (1) hide show
  1. test/test_invariants.py +10 -7
test/test_invariants.py CHANGED
@@ -2,12 +2,13 @@
2
  Invariant tests for cterdam/iso_3166-2 dataset.
3
 
4
  Run from dataset root after cloning:
 
5
  pytest test/test_invariants.py -v
6
 
7
  Verifies:
8
  - name field matches lang selection (name_en/ru/zh)
9
  - hash = SHA256(name)
10
- - lang matches parent region's language rule
11
  - hash format is 64-char hex string
12
  """
13
 
@@ -25,11 +26,11 @@ SINOPHONE_REGIONS = {
25
  }
26
 
27
 
28
- def determine_expected_lang(region: str) -> str:
29
- """Determine expected lang from parent region code."""
30
- if region in SINOPHONE_REGIONS:
31
  return 'zh'
32
- elif region in SLAVIC_REGIONS:
33
  return 'ru'
34
  else:
35
  return 'en'
@@ -37,7 +38,8 @@ def determine_expected_lang(region: str) -> str:
37
 
38
  @pytest.fixture(scope="session")
39
  def dataset():
40
- return load_dataset('.', split='train')
 
41
 
42
 
43
  def test_lang_values_valid(dataset):
@@ -113,4 +115,5 @@ def test_lang_matches_parent_region(dataset):
113
  if len(mismatches) >= 5:
114
  break
115
 
116
- assert mismatches == [], f"Lang mismatches: {mismatches}"
 
 
2
  Invariant tests for cterdam/iso_3166-2 dataset.
3
 
4
  Run from dataset root after cloning:
5
+ pip install datasets pytest
6
  pytest test/test_invariants.py -v
7
 
8
  Verifies:
9
  - name field matches lang selection (name_en/ru/zh)
10
  - hash = SHA256(name)
11
+ - lang matches region-based language rule
12
  - hash format is 64-char hex string
13
  """
14
 
 
26
  }
27
 
28
 
29
+ def determine_expected_lang(region_code: str) -> str:
30
+ """Determine expected lang from region code."""
31
+ if region_code in SINOPHONE_REGIONS:
32
  return 'zh'
33
+ elif region_code in SLAVIC_REGIONS:
34
  return 'ru'
35
  else:
36
  return 'en'
 
38
 
39
  @pytest.fixture(scope="session")
40
  def dataset():
41
+ """Load dataset from HF Hub."""
42
+ return load_dataset('cterdam/iso_3166-2', split='train')
43
 
44
 
45
  def test_lang_values_valid(dataset):
 
115
  if len(mismatches) >= 5:
116
  break
117
 
118
+ assert mismatches == [], f"Lang mismatches: {{mismatches}}"
119
+