cterdam commited on
Commit
22dd362
·
1 Parent(s): 3f925c0

Strict script-purity tests for name_zh and name_ru

Browse files

Replaces the earlier no-Latin/no-Cyrillic checks with comprehensive tests
that flag any letter character outside the target script (catches Greek,
Arabic, etc., not just Latin/Cyrillic).

Data fix: SKU name_ru contained Greek omicron (U+03BF) where Cyrillic o
(U+043E) was intended ('Скирοс' → 'Скирос').

Files changed (1) hide show
  1. test/test_invariants.py +24 -10
test/test_invariants.py CHANGED
@@ -358,18 +358,32 @@ def test_name_zh_no_latin(dataset):
358
  assert bad == [], f"name_zh with Latin letters: {bad[:10]}"
359
 
360
 
361
- def test_name_zh_no_cyrillic(dataset):
362
- """name_zh must not contain Cyrillic characters."""
363
- bad = [(e['code'], e['name_zh']) for e in dataset
364
- if e.get('name_zh') and _has_cyrillic(e['name_zh'])]
365
- assert bad == [], f"name_zh with Cyrillic: {bad[:10]}"
 
 
 
 
 
 
 
 
366
 
367
 
368
- def test_name_ru_no_foreign_letters(dataset):
369
- """name_ru must not contain Latin or CJK characters."""
370
- bad = [(e['code'], e['name_ru']) for e in dataset
371
- if e.get('name_ru') and re.search(r'[A-Za-z]', e['name_ru'])]
372
- assert bad == [], f"name_ru with Latin letters: {bad[:10]}"
 
 
 
 
 
 
373
 
374
 
375
  def test_no_double_spaces_in_names(dataset):
 
358
  assert bad == [], f"name_zh with Latin letters: {bad[:10]}"
359
 
360
 
361
+ def test_name_zh_only_cjk_letters(dataset):
362
+ """All letter characters in name_zh must be CJK (no Latin, Cyrillic, etc.)."""
363
+ bad = []
364
+ for e in dataset:
365
+ v = e.get('name_zh')
366
+ if not v:
367
+ continue
368
+ foreign = [c for c in v if c.isalpha() and not (
369
+ '㐀' <= c <= '鿿' or '豈' <= c <= '﫿'
370
+ )]
371
+ if foreign:
372
+ bad.append((e['code'], v, foreign))
373
+ assert bad == [], f"name_zh with non-CJK letters: {bad[:10]}"
374
 
375
 
376
+ def test_name_ru_only_cyrillic_letters(dataset):
377
+ """All letter characters in name_ru must be Cyrillic."""
378
+ bad = []
379
+ for e in dataset:
380
+ v = e.get('name_ru')
381
+ if not v:
382
+ continue
383
+ foreign = [c for c in v if c.isalpha() and not ('Ѐ' <= c <= 'ӿ')]
384
+ if foreign:
385
+ bad.append((e['code'], v, foreign))
386
+ assert bad == [], f"name_ru with non-Cyrillic letters: {bad[:10]}"
387
 
388
 
389
  def test_no_double_spaces_in_names(dataset):