Exemple #1
0
def test_simple_replace_shapes_with_paths(shape: str, expected_path: str):
  actual = (SVG.fromstring(svg_string(shape))
            .shapes_to_paths(inplace=True)
            .tostring())
  expected_result = (SVG.fromstring(svg_string(f'<path d="{expected_path}"/>'))
                     .tostring())
  print(f'A: {actual}')
  print(f'E: {expected_result}')
  assert actual == expected_result
Exemple #2
0
def test_path_move(path: str, move, expected_result: str):
  actual = (SVG.fromstring(svg_string(path))
            .shapes_to_paths())
  for shape in actual.shapes():
    shape.move(move.x, move.y, inplace=True)
  actual = actual.tostring()
  expected_result = (SVG.fromstring(svg_string(expected_result))
                     .tostring())
  print(f'A: {actual}')
  print(f'E: {expected_result}')
  assert actual == expected_result
Exemple #3
0
def test_iter(shape, expected_cmds):
  svg_path = (SVG.fromstring(svg_string(shape))
              .shapes_to_paths()
              .shapes()[0])
  actual_cmds = [t for t in svg_path]
  print(f'A: {actual_cmds}')
  print(f'E: {expected_cmds}')
  assert actual_cmds == expected_cmds
Exemple #4
0
def test_parse_common_attrib(shape, expected_attrib):
  svg = SVG.fromstring(shape)
  field_values = dataclasses.asdict(svg.shapes()[0])
  for attrib, expected_value in expected_attrib.items():
    assert field_values[attrib] == expected_value