예제 #1
0
 def test_no_name(self):
     inputstr = ";OffsetX:2"
     with CapturingLogHandler(builder.logger, "ERROR") as captor:
         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 with no filter name should trigger an error message",
     )
예제 #2
0
 def test_single_name(self):
     inputstr = 'AddExtremes'
     expected = {
         'name': 'AddExtremes',
     }
     result = parse_glyphs_filter(inputstr)
     self.assertEqual(result, expected)
예제 #3
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)
예제 #4
0
 def test_is_pre(self):
     inputstr = 'Dummy'
     expected = {
         'name': 'Dummy',
         'pre': True,
     }
     result = parse_glyphs_filter(inputstr, is_pre=True)
     self.assertEqual(result, expected)
 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)
예제 #6
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')
    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)
예제 #8
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)
예제 #9
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)
예제 #10
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)
예제 #11
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)
예제 #12
0
 def test_single_name(self):
     inputstr = "AddExtremes"
     expected = {"name": "AddExtremes"}
     result = parse_glyphs_filter(inputstr)
     self.assertEqual(result, expected)
예제 #13
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)
예제 #14
0
 def test_is_pre(self):
     inputstr = "Dummy"
     expected = {"name": "Dummy", "pre": True}
     result = parse_glyphs_filter(inputstr, is_pre=True)
     self.assertEqual(result, expected)