def get_target(cls, obj): objtype = obj.__class__.__name__ group = sanitize_identifier(obj.group) label = ('.' + sanitize_identifier(obj.label) if obj.label else '') target = '{objtype}.{group}{label}'.format(objtype=objtype, group=group, label=label) return (None, target) if hasattr(obj, 'values') else (target, None)
def get_target(cls, obj): objtype=obj.__class__.__name__ group = sanitize_identifier(obj.group) label = ('.'+sanitize_identifier(obj.label) if obj.label else '') target = '{objtype}.{group}{label}'.format(objtype=objtype, group=group, label=label) return (None, target) if hasattr(obj, 'values') else (target, None)
def test_arabic_five_sanitized_py3(self): """ Note: There would be a clash if you mixed the languages of your digits! E.g arabic ٥ five and urdu ۵ five """ try: sanitize_identifier('٥', version=3) except SyntaxError as e: assert str(e).startswith("String '٥' cannot be sanitized")
def test_urdu_a_five_sanitized_py3(self): """ Note: There would be a clash if you mixed the languages of your digits! E.g arabic ٥ five and urdu ۵ five """ sanitized = sanitize_identifier('a ۵', version=3) self.assertEqual(sanitized, 'A_۵')
def test_urdu_five_sanitized_py3(self): try: sanitize_identifier('۵', version=3) except SyntaxError as e: assert str(e).startswith("String '۵' cannot be sanitized")
def test_simple_a_pound_sanitized_py2(self): sanitized = sanitize_identifier('a £', version=2) self.assertEqual(sanitized, 'A_pound')
def test_custom_dollar_removal_py2(self): sanitize_identifier.eliminations.extend(['dollar']) sanitized = sanitize_identifier('$E$', version=3) self.assertEqual(sanitized, 'E') sanitize_identifier.eliminations.remove('dollar')
def test_capital_delta_sanitized_py2(self): sanitized = sanitize_identifier('Δ', version=2) self.assertEqual(sanitized, 'Delta')
def test_simple_alpha_sanitized_py2(self): sanitized = sanitize_identifier('α', version=2) self.assertEqual(sanitized, 'alpha')
def test_simple_digit_sanitized_py2(self): sanitized = sanitize_identifier('0', version=2) self.assertEqual(sanitized, 'A_0')
def test_simple_alpha_beta_mixed_underscore_space_sanitized_py3(self): sanitized = sanitize_identifier('α__ β', version=3) self.assertEqual(sanitized, 'α__β')
def test_simple_alpha_beta_double_underscore_sanitized_py2(self): sanitized = sanitize_identifier('α__β', version=2) self.assertEqual(sanitized, 'alpha__beta')
def test_simple_dollar_sanitized_py3(self): sanitized = sanitize_identifier('$', version=3) self.assertEqual(sanitized, 'dollar')
def test_umlaut_sanitized_py2(self): sanitized = sanitize_identifier('Festkörperphysik', version=2) self.assertEqual(sanitized, 'Festkorperphysik')
def test_alpha_times_two_py3(self): sanitized = sanitize_identifier('α*2', version=3) self.assertEqual(sanitized, 'α_times_2')
def test_simple_alpha_beta_sanitized_py3(self): sanitized = sanitize_identifier('α β', version=3) self.assertEqual(sanitized, 'α_β')
def test_power_umlaut_sanitized_py3(self): sanitized = sanitize_identifier('^Festkörperphysik', version=3) self.assertEqual(sanitized, 'power_Festkörperphysik')
def test_simple_underscore_sanitized_py2(self): sanitized = sanitize_identifier('_test', version=2) self.assertEqual(sanitized, 'A__test')
def test_simple_a_dollar_sanitized_py2(self): sanitized = sanitize_identifier('a $', version=2) self.assertEqual(sanitized, 'A_dollar')
def test_lowercase_delta_sanitized_py2(self): sanitized = sanitize_identifier('δ', version=2) self.assertEqual(sanitized, 'delta')
def test_simple_pound_sanitized_py3(self): sanitized = sanitize_identifier('£', version=3) self.assertEqual(sanitized, 'pound')