11# -*- coding: utf-8 -*-
22
3- from mathics_scanner .generate .build_tables import DEFAULT_DATA_DIR
4- import yaml
3+ from util import yaml_data
54import unicodedata
65
7- def check_attr_is_invertible (yaml_data : dict , attr : str ):
6+ def check_attr_is_invertible (attr : str ):
87 for v in yaml_data .values ():
98 if attr in v :
109 attr_v = v [attr ]
@@ -17,12 +16,12 @@ def check_attr_is_invertible(yaml_data: dict, attr: str):
1716 ), f"{ attr_vs } all have the same { attr } field set to { attr_v } "
1817
1918
20- def check_has_attr (yaml_data : dict , attr : str ):
19+ def check_has_attr (attr : str ):
2120 for k , v in yaml_data .items ():
2221 assert attr in v , f"{ k } has no { attr } attribute"
2322
2423
25- def check_wl_unicode_name (yaml_data : dict ):
24+ def check_wl_unicode_name ():
2625 for k , v in yaml_data .items ():
2726 wl = v ["wl-unicode" ]
2827
@@ -49,7 +48,7 @@ def check_wl_unicode_name(yaml_data: dict):
4948 ), f"{ k } has wl-unicode-name set to { real_name } but it should be { expected_name } "
5049
5150
52- def check_unicode_name (yaml_data : dict ):
51+ def check_unicode_name ():
5352 for k , v in yaml_data .items ():
5453 # Hack to skip characters that are correct but that doesn't show up in
5554 # unicodedata.name
@@ -79,19 +78,16 @@ def check_unicode_name(yaml_data: dict):
7978
8079
8180def test_general_yaml_sanity ():
82- with open (DEFAULT_DATA_DIR / "named-characters.yml" , "r" ) as yaml_file :
83- yaml_data = yaml .load (yaml_file , Loader = yaml .FullLoader )
84-
85- # Check if required attributes are in place
86- check_has_attr (yaml_data , "wl-unicode" )
87- check_has_attr (yaml_data , "is-letter-like" )
88- check_has_attr (yaml_data , "has-unicode-inverse" )
89-
90- # Check if attributes that should be invertible are in fact invertible
91- check_attr_is_invertible (yaml_data , "wl-unicode" )
92- check_attr_is_invertible (yaml_data , "esc-alias" )
93-
94- # Check the consistency of the unicode names in the table
95- check_wl_unicode_name (yaml_data )
96- check_unicode_name (yaml_data )
81+ # Check if required attributes are in place
82+ check_has_attr ("wl-unicode" )
83+ check_has_attr ("is-letter-like" )
84+ check_has_attr ("has-unicode-inverse" )
85+
86+ # Check if attributes that should be invertible are in fact invertible
87+ check_attr_is_invertible ("wl-unicode" )
88+ check_attr_is_invertible ("esc-alias" )
89+
90+ # Check the consistency of the unicode names in the table
91+ check_wl_unicode_name ()
92+ check_unicode_name ()
9793
0 commit comments