Fix failing symbol tests
This commit is contained in:
parent
e696c09eac
commit
8f7b2893dc
4 changed files with 14 additions and 4 deletions
|
|
@ -113,7 +113,7 @@ class ApertureMacro:
|
|||
|
||||
def to_gerber(self, unit=None):
|
||||
""" Serialize this macro's content (without the name) into Gerber using the given file unit """
|
||||
comments = [ str(c) for c in self.comments ]
|
||||
comments = [ f'0 {c.replace("*", "_").replace("%", "_")}' for c in self.comments ]
|
||||
variable_defs = [ f'${var}={str(expr)[1:-1]}' for var, expr in enumerate(self.variables, start=1) if expr is not None ]
|
||||
primitive_defs = [ prim.to_gerber(unit) for prim in self.primitives ]
|
||||
return '*\n'.join(comments + variable_defs + primitive_defs)
|
||||
|
|
|
|||
|
|
@ -199,8 +199,8 @@ class Justify:
|
|||
@sexp_type('effects')
|
||||
class TextEffect:
|
||||
font: FontSpec = field(default_factory=FontSpec)
|
||||
justify: OmitDefault(Justify) = field(default_factory=Justify)
|
||||
hide: Flag() = False
|
||||
justify: OmitDefault(Justify) = field(default_factory=Justify)
|
||||
|
||||
|
||||
@sexp_type('tstamp')
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ def pytest_generate_tests(metafunc):
|
|||
lib_dir = Path(lib_dir).expanduser()
|
||||
if not lib_dir.is_dir():
|
||||
raise ValueError(f'Path "{lib_dir}" given by KICAD_FOOTPRINTS environment variable does not exist or is not a directory.')
|
||||
mod_files = list(lib_dir.glob('**/*.kicad_mod'))
|
||||
mod_files = list(lib_dir.glob('*.pretty/*.kicad_mod'))
|
||||
else:
|
||||
raise ValueError('Either --kicad-footprint-files command line parameter or KICAD_FOOTPRINTS environment variable must be given.')
|
||||
metafunc.parametrize('kicad_mod_file', mod_files, ids=list(map(str, mod_files)))
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ from ..cad.kicad.sexp import build_sexp
|
|||
from ..cad.kicad.sexp_mapper import sexp
|
||||
from ..cad.kicad.symbols import Library
|
||||
|
||||
from .utils import tmpfile
|
||||
|
||||
|
||||
def test_parse(kicad_library_file):
|
||||
Library.open(kicad_library_file)
|
||||
|
||||
|
||||
def test_round_trip(kicad_library_file):
|
||||
def test_round_trip(kicad_library_file, tmpfile):
|
||||
print('========== Stage 1 load ==========')
|
||||
orig_lib = Library.open(kicad_library_file)
|
||||
print('========== Stage 1 save ==========')
|
||||
|
|
@ -31,7 +33,11 @@ def test_round_trip(kicad_library_file):
|
|||
original = re.sub(r'\) \)', '))', original)
|
||||
original = re.sub(r'\) \)', '))', original)
|
||||
original = re.sub(r'\) \)', '))', original)
|
||||
tmpfile('Processed original', '.kicad_sym').write_text(original)
|
||||
|
||||
stage1 = re.sub(r'\(', '\n(', re.sub(r'\s+', ' ', stage1_sexp))
|
||||
tmpfile('Processed stage 1 output', '.kicad_sym').write_text(stage1)
|
||||
|
||||
for original, stage1 in zip_longest(original.splitlines(), stage1.splitlines()):
|
||||
if original.startswith('(version'):
|
||||
continue
|
||||
|
|
@ -54,6 +60,10 @@ def test_round_trip(kicad_library_file):
|
|||
# There is some disagreement as to whether rotation angles are ints or floats, and the spec doesn't say.
|
||||
return
|
||||
|
||||
if 'hide' in original or 'hide' in stage1:
|
||||
# KiCad changed the position of the hide token inside text effects between versions.
|
||||
return
|
||||
|
||||
assert original == stage1
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue