From 94f3976915d64a77135a1fdc8983085ee8d2e1f9 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Thu, 11 Jun 2015 11:20:56 -0400 Subject: Add keys to statements for linking to primitives. Add some API features to ExcellonFile, such as getting a tool path length and changing tool parameters. Excellonfiles write method generates statements based on the drill hits in the hits member, so drill hits in a generated file can be re-ordered by re-ordering the drill hits in ExcellonFile.hits. see #30 --- gerber/tests/test_excellon.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index d47ad6a..006277d 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -24,6 +24,17 @@ def test_read(): ncdrill = read(NCDRILL_FILE) assert(isinstance(ncdrill, ExcellonFile)) +def test_write(): + ncdrill = read(NCDRILL_FILE) + ncdrill.write('test.ncd') + with open(NCDRILL_FILE) as src: + srclines = src.readlines() + + with open('test.ncd') as res: + for idx, line in enumerate(res): + assert_equal(line.strip(), srclines[idx].strip()) + os.remove('test.ncd') + def test_read_settings(): ncdrill = read(NCDRILL_FILE) assert_equal(ncdrill.settings['format'], (2, 4)) @@ -47,9 +58,11 @@ def test_conversion(): ncdrill.to_metric() assert_equal(ncdrill.settings.units, 'metric') + inch_primitives = ncdrill_inch.primitives + for tool in iter(ncdrill_inch.tools.values()): tool.to_metric() - for primitive in ncdrill_inch.primitives: + for primitive in inch_primitives: primitive.to_metric() for statement in ncdrill_inch.statements: statement.to_metric() @@ -57,7 +70,7 @@ def test_conversion(): for m_tool, i_tool in zip(iter(ncdrill.tools.values()), iter(ncdrill_inch.tools.values())): assert_equal(i_tool, m_tool) - for m, i in zip(ncdrill.primitives,ncdrill_inch.primitives): + for m, i in zip(ncdrill.primitives,inch_primitives): assert_equal(m, i) -- cgit