diff options
author | jaseg <git@jaseg.de> | 2023-11-09 19:16:37 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-11-14 21:52:12 +0100 |
commit | 74fb384c4c0899f4d6f153da8db748a7a49e78ee (patch) | |
tree | 6e956d0fb498f1e47b995ec6093827f2a5395fc8 /gerbonara/tests | |
parent | 9af071344523accb5ae094ec76d5ace8102f1b0e (diff) | |
download | gerbonara-74fb384c4c0899f4d6f153da8db748a7a49e78ee.tar.gz gerbonara-74fb384c4c0899f4d6f153da8db748a7a49e78ee.tar.bz2 gerbonara-74fb384c4c0899f4d6f153da8db748a7a49e78ee.zip |
aperture macros: work around gerbv/jlc wonkiness
Diffstat (limited to 'gerbonara/tests')
-rw-r--r-- | gerbonara/tests/image_support.py | 2 | ||||
-rw-r--r-- | gerbonara/tests/test_cli.py | 48 |
2 files changed, 25 insertions, 25 deletions
diff --git a/gerbonara/tests/image_support.py b/gerbonara/tests/image_support.py index 64f59ea..b1b0f59 100644 --- a/gerbonara/tests/image_support.py +++ b/gerbonara/tests/image_support.py @@ -162,7 +162,7 @@ def kicad_fp_export(mod_file, out_svg): fp_name = mod_file.name[:-len('.kicad_mod')] cmd = ['podman', 'run', '--mount', f'type=bind,src={pretty_dir},dst=/{pretty_dir.name}', '--mount', f'type=bind,src={tmpdir},dst=/out', - 'registry.gitlab.com/kicad/kicad-ci/kicad-cli-docker/kicad:nightly', + 'registry.hub.docker.com/kicad/kicad:nightly', 'kicad-cli', 'fp', 'export', 'svg', '--output', '/out', '--footprint', fp_name, f'/{pretty_dir.name}'] subprocess.run(cmd, check=True) #, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) out_file = Path(tmpdir) / f'{fp_name}.svg' diff --git a/gerbonara/tests/test_cli.py b/gerbonara/tests/test_cli.py index d5a0ad4..22f5a72 100644 --- a/gerbonara/tests/test_cli.py +++ b/gerbonara/tests/test_cli.py @@ -43,28 +43,28 @@ def file_mock(): class TestRender: - def invoke(self, *args): + def invoke(self, outfile, *args): runner = CliRunner() res = runner.invoke(cli.render, list(map(str, args))) - print(res.output) + outfile.write_text(str(res.output)) if res.exception: raise res.exception assert res.exit_code == 0 return res.output - def test_basic(self): - assert self.invoke('--version').startswith('Version ') + def test_basic(self, tmpfile): + assert self.invoke(tmpfile('Standard output', '.svg'), '--version').startswith('Version ') @pytest.mark.parametrize('reference', ['example_flash_obround.gbr'], indirect=True) - def test_warnings(self, reference): + def test_warnings(self, reference, tmpfile): with pytest.warns(UserWarning): - self.invoke(reference, '--warnings=once') + self.invoke(tmpfile('Standard output', '.svg'), reference, '--warnings=once') @pytest.mark.parametrize('reference', ['kicad-older'], indirect=True) - def test_side(self, reference): - without = self.invoke(reference, '--warnings=ignore') - top = self.invoke(reference, '--top', '--warnings=ignore') - bottom = self.invoke(reference, '--bottom', '--warnings=ignore') + def test_side(self, reference, tmpfile): + without = self.invoke(tmpfile('Standard output, without args', '.svg'), reference, '--warnings=ignore') + top = self.invoke(tmpfile('Standard output, --top', '.svg'), reference, '--top', '--warnings=ignore') + bottom = self.invoke(tmpfile('Standard output, --bottom', '.svg'), reference, '--bottom', '--warnings=ignore') assert top.strip().startswith('<?xml') assert bottom.strip().startswith('<?xml') assert '<path' in top @@ -133,22 +133,22 @@ class TestRender: class TestRewrite: - def invoke(self, *args): + def invoke(self, outfile, *args): runner = CliRunner() res = runner.invoke(cli.rewrite, list(map(str, args))) - print(res.output) + outfile.write_text(res.output) if res.exception: raise res.exception assert res.exit_code == 0 return res.output - def test_basic(self): - assert self.invoke('--version').startswith('Version ') + def test_basic(self, tmpfile): + assert self.invoke(tmpfile('Standard output', '.svg'), '--version').startswith('Version ') @pytest.mark.parametrize('reference', ['example_flash_obround.gbr'], indirect=True) - def test_transforms(self, reference, file_mock): + def test_transforms(self, reference, file_mock, tmpfile): with tempfile.NamedTemporaryFile() as tmpout: - self.invoke(reference, tmpout.name, '--transform', 'rotate(90); translate(10, 10); rotate(-45.5); scale(2)') + self.invoke(tmpfile('Standard output', '.svg'), reference, tmpout.name, '--transform', 'rotate(90); translate(10, 10); rotate(-45.5); scale(2)') file_mock.rotate.assert_has_calls([ mock.call(math.radians(90), 0, 0, MM), mock.call(math.radians(-45.5), 0, 0, MM)]) @@ -158,9 +158,9 @@ class TestRewrite: assert file_mock.save.call_args[0][0] == tmpout.name @pytest.mark.parametrize('reference', ['example_flash_obround.gbr'], indirect=True) - def test_real_invocation(self, reference): + def test_real_invocation(self, reference, tmpfile): with tempfile.NamedTemporaryFile() as tmpout: - self.invoke(reference, tmpout.name, '--transform', 'rotate(45); translate(10, 0)') + self.invoke(tmpfile('Standard output', '.svg'), reference, tmpout.name, '--transform', 'rotate(45); translate(10, 0)') assert tmpout.read() @@ -188,19 +188,19 @@ class TestMerge: class TestMeta: - def invoke(self, *args): + def invoke(self, outfile, *args): runner = CliRunner() res = runner.invoke(cli.meta, list(map(str, args))) - print(res.output) + outfile.write_text(str(res.output)) if res.exception: raise res.exception assert res.exit_code == 0 return res.output - def test_basic(self): - assert self.invoke('--version').startswith('Version ') + def test_basic(self, tmpfile): + assert self.invoke(tmpfile('Standard output', '.svg'), '--version').startswith('Version ') @pytest.mark.parametrize('reference', ['example_flash_obround.gbr'], indirect=True) - def test_real_invocation(self, reference): - j = json.loads(self.invoke(reference, '--warnings', 'ignore')) + def test_real_invocation(self, reference, tmpfile): + j = json.loads(self.invoke(tmpfile('Standard output', '.svg'), reference, '--warnings', 'ignore')) |