1
0
Fork 0
inkscape/share/extensions/other/extension-afdesign/tests/conftest.py
Daniel Baumann 02d935e272
Adding upstream version 1.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-22 23:40:13 +02:00

33 lines
961 B
Python

# Copyright (C) 2024 Jonathan Neuhauser <jonathan.neuhauser@outlook.com>
# SPDX-License-Identifier: GPL-2.0-or-later
import os
import sys
from inkaf.parser.types import AFDictObject, AFListObject
HERE = os.path.dirname(__file__) or "."
# This is suggested by https://docs.python-guide.org/writing/structure/.
sys.path.insert(0, os.path.abspath(os.path.join(HERE, "..")))
def assert_remove_parents(result, expected):
"""Remove parents from AFObjects and compare"""
def _remove_parents(entry):
if isinstance(entry, AFDictObject):
for field in entry.fields.values():
field.parent = None
if isinstance(entry, AFListObject):
for field in entry.fields:
field.parent = None
current = result.value
if isinstance(current, list):
for entry in current:
_remove_parents(entry)
else:
_remove_parents(current)
assert result.value == expected