示例#1
0
 def test_single_name(self):
     inputstr = 'AddExtremes'
     expected = {
         'name': 'AddExtremes',
     }
     result = parse_glyphs_filter(inputstr)
     self.assertEqual(result, expected)
示例#2
0
 def test_positional_parameter(self):
     inputstr = 'Roughenizer;34;2;0;0.34'
     expected = {
         'name': 'Roughenizer',
         'args': [34, 2, 0, 0.34],
     }
     result = parse_glyphs_filter(inputstr)
     self.assertEqual(result, expected)
示例#3
0
 def test_empty_string(self):
     inputstr = ''
     with CapturingLogHandler(builder.logger, "ERROR") as captor:
         result = parse_glyphs_filter(inputstr)
     self.assertGreater(len([
         r for r in captor.records
         if 'Failed to parse glyphs filter' in r.msg
     ]),
                        0,
                        msg='Empty string should trigger an error message')
示例#4
0
 def test_complete_parameter(self):
     inputstr = 'Transformations;LSB:+23;RSB:-22;SlantCorrection:true;OffsetX:10;OffsetY:-10;Origin:0;exclude:uni0334,uni0335 uni0336'
     expected = {
         'name': 'Transformations',
         'kwargs': {
             'LSB': 23,
             'RSB': -22,
             'SlantCorrection': True,
             'OffsetX': 10,
             'OffsetY': -10,
             'Origin': 0,
         },
         'exclude': ['uni0334', 'uni0335', 'uni0336'],
     }
     result = parse_glyphs_filter(inputstr)
     self.assertEqual(result, expected)
示例#5
0
    def test_duplicate_exclude_include(self):
        inputstr = 'thisisaname;34;-3.4;exclude:uni1111;include:uni0022;exclude:uni2222'
        expected = {
            'name': 'thisisaname',
            'args': [34, -3.4],
            'exclude': ['uni2222'],
        }
        with CapturingLogHandler(builder.logger, "ERROR") as captor:
            result = parse_glyphs_filter(inputstr)

        self.assertGreater(
            len([
                r for r in captor.records
                if 'can only present as the last argument' in r.msg
            ]),
            0,
            msg=
            'The parse_glyphs_filter should warn user that the exclude/include should only be the last argument in the filter string.'
        )
        self.assertEqual(result, expected)
示例#6
0
 def test_empty_args_trailing_semicolon(self):
     inputstr = 'thisisaname;3;;a:b;;;'
     expected = {'name': 'thisisaname', 'args': [3], 'kwargs': {'a': 'b'}}
     result = parse_glyphs_filter(inputstr)
     self.assertEqual(result, expected)