From b495d51354eff7b858dbbd41740865eba7f39100 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Sun, 25 Jan 2015 14:19:48 -0500 Subject: Changed zeros/zero suppression conventions to match file format specs --- gerber/tests/test_excellon.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index 72e3d7d..70e4560 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -15,18 +15,13 @@ def test_format_detection(): """ settings = detect_excellon_format(NCDRILL_FILE) assert_equal(settings['format'], (2, 4)) - assert_equal(settings['zero_suppression'], 'leading') + assert_equal(settings['zeros'], 'trailing') def test_read(): ncdrill = read(NCDRILL_FILE) assert(isinstance(ncdrill, ExcellonFile)) - + def test_read_settings(): ncdrill = read(NCDRILL_FILE) - assert_equal(ncdrill.settings.format, (2, 4)) - assert_equal(ncdrill.settings.zero_suppression, 'leading') - - - - - + assert_equal(ncdrill.settings['format'], (2, 4)) + assert_equal(ncdrill.settings['zeros'], 'trailing') -- cgit From 5cf1fa74b42eb8feaab23078bef6f31f6d647c33 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Sun, 15 Feb 2015 02:20:02 -0500 Subject: Tests and bugfixes --- gerber/tests/test_excellon.py | 112 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index 70e4560..de45b44 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -2,7 +2,8 @@ # -*- coding: utf-8 -*- # Author: Hamilton Kibbe -from ..excellon import read, detect_excellon_format, ExcellonFile +from ..cam import FileSettings +from ..excellon import read, detect_excellon_format, ExcellonFile, ExcellonParser from tests import * import os @@ -25,3 +26,112 @@ def test_read_settings(): ncdrill = read(NCDRILL_FILE) assert_equal(ncdrill.settings['format'], (2, 4)) assert_equal(ncdrill.settings['zeros'], 'trailing') + +def test_bounds(): + ncdrill = read(NCDRILL_FILE) + xbound, ybound = ncdrill.bounds + assert_array_almost_equal(xbound, (0.1300, 2.1430)) + assert_array_almost_equal(ybound, (0.3946, 1.7164)) + +def test_report(): + ncdrill = read(NCDRILL_FILE) + +def test_parser_hole_count(): + settings = FileSettings(**detect_excellon_format(NCDRILL_FILE)) + p = ExcellonParser(settings) + p.parse(NCDRILL_FILE) + assert_equal(p.hole_count, 36) + +def test_parser_hole_sizes(): + settings = FileSettings(**detect_excellon_format(NCDRILL_FILE)) + p = ExcellonParser(settings) + p.parse(NCDRILL_FILE) + assert_equal(p.hole_sizes, [0.0236, 0.0354, 0.04, 0.126, 0.128]) + +def test_parse_whitespace(): + p = ExcellonParser(FileSettings()) + assert_equal(p._parse(' '), None) + +def test_parse_comment(): + p = ExcellonParser(FileSettings()) + p._parse(';A comment') + assert_equal(p.statements[0].comment, 'A comment') + +def test_parse_format_comment(): + p = ExcellonParser(FileSettings()) + p._parse('; FILE_FORMAT=9:9 ') + assert_equal(p.format, (9, 9)) + +def test_parse_header(): + p = ExcellonParser(FileSettings()) + p._parse('M48 ') + assert_equal(p.state, 'HEADER') + p._parse('M95 ') + assert_equal(p.state, 'DRILL') + +def test_parse_rout(): + p = ExcellonParser(FileSettings()) + p._parse('G00 ') + assert_equal(p.state, 'ROUT') + p._parse('G05 ') + assert_equal(p.state, 'DRILL') + +def test_parse_version(): + p = ExcellonParser(FileSettings()) + p._parse('VER,1 ') + assert_equal(p.statements[0].version, 1) + p._parse('VER,2 ') + assert_equal(p.statements[1].version, 2) + +def test_parse_format(): + p = ExcellonParser(FileSettings()) + p._parse('FMAT,1 ') + assert_equal(p.statements[0].format, 1) + p._parse('FMAT,2 ') + assert_equal(p.statements[1].format, 2) + +def test_parse_units(): + settings = FileSettings(units='inch', zeros='trailing') + p = ExcellonParser(settings) + p._parse(';METRIC,LZ') + assert_equal(p.units, 'inch') + assert_equal(p.zeros, 'trailing') + p._parse('METRIC,LZ') + assert_equal(p.units, 'metric') + assert_equal(p.zeros, 'leading') + +def test_parse_incremental_mode(): + settings = FileSettings(units='inch', zeros='trailing') + p = ExcellonParser(settings) + assert_equal(p.notation, 'absolute') + p._parse('ICI,ON ') + assert_equal(p.notation, 'incremental') + p._parse('ICI,OFF ') + assert_equal(p.notation, 'absolute') + +def test_parse_absolute_mode(): + settings = FileSettings(units='inch', zeros='trailing') + p = ExcellonParser(settings) + assert_equal(p.notation, 'absolute') + p._parse('ICI,ON ') + assert_equal(p.notation, 'incremental') + p._parse('G90 ') + assert_equal(p.notation, 'absolute') + +def test_parse_repeat_hole(): + p = ExcellonParser(FileSettings()) + p._parse('R03X1.5Y1.5') + assert_equal(p.statements[0].count, 3) + +def test_parse_incremental_position(): + p = ExcellonParser(FileSettings(notation='incremental')) + p._parse('X01Y01') + p._parse('X01Y01') + assert_equal(p.pos, [2.,2.]) + +def test_parse_unknown(): + p = ExcellonParser(FileSettings()) + p._parse('Not A Valid Statement') + assert_equal(p.statements[0].stmt, 'Not A Valid Statement') + + -- cgit From bfe14841604b6be403e7123e8b6667b1f0aff6f6 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Sun, 15 Feb 2015 03:29:47 -0500 Subject: Add cairo example code, and use example-generated image in readme --- gerber/tests/test_excellon.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index de45b44..ea067b5 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -4,6 +4,7 @@ # Author: Hamilton Kibbe from ..cam import FileSettings from ..excellon import read, detect_excellon_format, ExcellonFile, ExcellonParser +from ..excellon_statements import ExcellonTool from tests import * import os @@ -120,6 +121,7 @@ def test_parse_absolute_mode(): def test_parse_repeat_hole(): p = ExcellonParser(FileSettings()) + p.active_tool = ExcellonTool(FileSettings(), number=8) p._parse('R03X1.5Y1.5') assert_equal(p.statements[0].count, 3) -- cgit From 288ac27084b47166ac662402ea340d0aa25d8f56 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Wed, 18 Feb 2015 04:31:23 -0500 Subject: Get unit conversion working for Gerber/Excellon files Started operations module for file operations/transforms --- gerber/tests/test_excellon.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index ea067b5..24cf793 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -2,12 +2,13 @@ # -*- coding: utf-8 -*- # Author: Hamilton Kibbe +import os + from ..cam import FileSettings from ..excellon import read, detect_excellon_format, ExcellonFile, ExcellonParser from ..excellon_statements import ExcellonTool from tests import * -import os NCDRILL_FILE = os.path.join(os.path.dirname(__file__), 'resources/ncdrill.DRD') @@ -37,6 +38,29 @@ def test_bounds(): def test_report(): ncdrill = read(NCDRILL_FILE) + +def test_conversion(): + import copy + ncdrill = read(NCDRILL_FILE) + assert_equal(ncdrill.settings.units, 'inch') + ncdrill_inch = copy.deepcopy(ncdrill) + ncdrill.to_metric() + assert_equal(ncdrill.settings.units, 'metric') + + for tool in ncdrill_inch.tools.itervalues(): + tool.to_metric() + for primitive in ncdrill_inch.primitives: + primitive.to_metric() + for statement in ncdrill_inch.statements: + statement.to_metric() + + for m_tool, i_tool in zip(ncdrill.tools.itervalues(), ncdrill_inch.tools.itervalues()): + assert_equal(i_tool, m_tool) + + for m, i in zip(ncdrill.primitives,ncdrill_inch.primitives): + assert_equal(m, i) + + def test_parser_hole_count(): settings = FileSettings(**detect_excellon_format(NCDRILL_FILE)) p = ExcellonParser(settings) -- cgit From e71d7a24b5be3e68d36494869595eec934db4bd2 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Wed, 18 Feb 2015 21:14:30 -0500 Subject: Python 3 tests passing --- gerber/tests/test_excellon.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index 24cf793..d47ad6a 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -7,7 +7,7 @@ import os from ..cam import FileSettings from ..excellon import read, detect_excellon_format, ExcellonFile, ExcellonParser from ..excellon_statements import ExcellonTool -from tests import * +from .tests import * NCDRILL_FILE = os.path.join(os.path.dirname(__file__), @@ -47,14 +47,14 @@ def test_conversion(): ncdrill.to_metric() assert_equal(ncdrill.settings.units, 'metric') - for tool in ncdrill_inch.tools.itervalues(): + for tool in iter(ncdrill_inch.tools.values()): tool.to_metric() for primitive in ncdrill_inch.primitives: primitive.to_metric() for statement in ncdrill_inch.statements: statement.to_metric() - for m_tool, i_tool in zip(ncdrill.tools.itervalues(), ncdrill_inch.tools.itervalues()): + 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): -- cgit 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 From dd63b169f177389602e17bc6ced53bd0f1ba0de3 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Sat, 10 Oct 2015 16:51:21 -0400 Subject: Allow files to be read from strings per #37 Adds a loads() method to the top level module which generates a GerberFile or ExcellonFile from a string --- gerber/tests/test_excellon.py | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index 006277d..b821649 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -11,41 +11,51 @@ from .tests import * NCDRILL_FILE = os.path.join(os.path.dirname(__file__), - 'resources/ncdrill.DRD') + 'resources/ncdrill.DRD') def test_format_detection(): """ Test file type detection """ - settings = detect_excellon_format(NCDRILL_FILE) + with open(NCDRILL_FILE) as f: + data = f.read() + settings = detect_excellon_format(data) assert_equal(settings['format'], (2, 4)) assert_equal(settings['zeros'], 'trailing') + settings = detect_excellon_format(filename=NCDRILL_FILE) + assert_equal(settings['format'], (2, 4)) + assert_equal(settings['zeros'], 'trailing') + + 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() - + srclines = src.readlines() with open('test.ncd') as res: - for idx, line in enumerate(res): - assert_equal(line.strip(), srclines[idx].strip()) + 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)) assert_equal(ncdrill.settings['zeros'], 'trailing') + def test_bounds(): ncdrill = read(NCDRILL_FILE) xbound, ybound = ncdrill.bounds assert_array_almost_equal(xbound, (0.1300, 2.1430)) assert_array_almost_equal(ybound, (0.3946, 1.7164)) + def test_report(): ncdrill = read(NCDRILL_FILE) @@ -57,9 +67,7 @@ def test_conversion(): ncdrill_inch = copy.deepcopy(ncdrill) 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 inch_primitives: @@ -80,26 +88,31 @@ def test_parser_hole_count(): p.parse(NCDRILL_FILE) assert_equal(p.hole_count, 36) + def test_parser_hole_sizes(): settings = FileSettings(**detect_excellon_format(NCDRILL_FILE)) p = ExcellonParser(settings) p.parse(NCDRILL_FILE) assert_equal(p.hole_sizes, [0.0236, 0.0354, 0.04, 0.126, 0.128]) + def test_parse_whitespace(): p = ExcellonParser(FileSettings()) assert_equal(p._parse(' '), None) + def test_parse_comment(): p = ExcellonParser(FileSettings()) p._parse(';A comment') assert_equal(p.statements[0].comment, 'A comment') + def test_parse_format_comment(): p = ExcellonParser(FileSettings()) p._parse('; FILE_FORMAT=9:9 ') assert_equal(p.format, (9, 9)) + def test_parse_header(): p = ExcellonParser(FileSettings()) p._parse('M48 ') @@ -107,6 +120,7 @@ def test_parse_header(): p._parse('M95 ') assert_equal(p.state, 'DRILL') + def test_parse_rout(): p = ExcellonParser(FileSettings()) p._parse('G00 ') @@ -114,6 +128,7 @@ def test_parse_rout(): p._parse('G05 ') assert_equal(p.state, 'DRILL') + def test_parse_version(): p = ExcellonParser(FileSettings()) p._parse('VER,1 ') @@ -121,6 +136,7 @@ def test_parse_version(): p._parse('VER,2 ') assert_equal(p.statements[1].version, 2) + def test_parse_format(): p = ExcellonParser(FileSettings()) p._parse('FMAT,1 ') @@ -128,6 +144,7 @@ def test_parse_format(): p._parse('FMAT,2 ') assert_equal(p.statements[1].format, 2) + def test_parse_units(): settings = FileSettings(units='inch', zeros='trailing') p = ExcellonParser(settings) @@ -138,6 +155,7 @@ def test_parse_units(): assert_equal(p.units, 'metric') assert_equal(p.zeros, 'leading') + def test_parse_incremental_mode(): settings = FileSettings(units='inch', zeros='trailing') p = ExcellonParser(settings) @@ -147,6 +165,7 @@ def test_parse_incremental_mode(): p._parse('ICI,OFF ') assert_equal(p.notation, 'absolute') + def test_parse_absolute_mode(): settings = FileSettings(units='inch', zeros='trailing') p = ExcellonParser(settings) @@ -156,18 +175,21 @@ def test_parse_absolute_mode(): p._parse('G90 ') assert_equal(p.notation, 'absolute') + def test_parse_repeat_hole(): p = ExcellonParser(FileSettings()) p.active_tool = ExcellonTool(FileSettings(), number=8) p._parse('R03X1.5Y1.5') assert_equal(p.statements[0].count, 3) + def test_parse_incremental_position(): p = ExcellonParser(FileSettings(notation='incremental')) p._parse('X01Y01') p._parse('X01Y01') assert_equal(p.pos, [2.,2.]) + def test_parse_unknown(): p = ExcellonParser(FileSettings()) p._parse('Not A Valid Statement') -- cgit From 6e29b9bcae8167dbb9c75e5a79e09886b952e988 Mon Sep 17 00:00:00 2001 From: Paulo Henrique Silva Date: Sun, 15 Nov 2015 22:28:56 -0200 Subject: Use Python's universal newlines to open files --- gerber/tests/test_excellon.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index b821649..705adc3 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -16,7 +16,7 @@ NCDRILL_FILE = os.path.join(os.path.dirname(__file__), def test_format_detection(): """ Test file type detection """ - with open(NCDRILL_FILE) as f: + with open(NCDRILL_FILE, "rU") as f: data = f.read() settings = detect_excellon_format(data) assert_equal(settings['format'], (2, 4)) @@ -35,9 +35,9 @@ def test_read(): def test_write(): ncdrill = read(NCDRILL_FILE) ncdrill.write('test.ncd') - with open(NCDRILL_FILE) as src: + with open(NCDRILL_FILE, "rU") as src: srclines = src.readlines() - with open('test.ncd') as res: + with open('test.ncd', "rU") as res: for idx, line in enumerate(res): assert_equal(line.strip(), srclines[idx].strip()) os.remove('test.ncd') -- cgit From 1cb269131bc52f0b1a1e69cef0466f2d994d52a8 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Sat, 19 Dec 2015 21:54:29 -0500 Subject: Allow negative render of soldermask per #50 Update example code and rendering to show change --- gerber/tests/test_excellon.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index 705adc3..a9a33c7 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -98,60 +98,60 @@ def test_parser_hole_sizes(): def test_parse_whitespace(): p = ExcellonParser(FileSettings()) - assert_equal(p._parse(' '), None) + assert_equal(p._parse_line(' '), None) def test_parse_comment(): p = ExcellonParser(FileSettings()) - p._parse(';A comment') + p._parse_line(';A comment') assert_equal(p.statements[0].comment, 'A comment') def test_parse_format_comment(): p = ExcellonParser(FileSettings()) - p._parse('; FILE_FORMAT=9:9 ') + p._parse_line('; FILE_FORMAT=9:9 ') assert_equal(p.format, (9, 9)) def test_parse_header(): p = ExcellonParser(FileSettings()) - p._parse('M48 ') + p._parse_line('M48 ') assert_equal(p.state, 'HEADER') - p._parse('M95 ') + p._parse_line('M95 ') assert_equal(p.state, 'DRILL') def test_parse_rout(): p = ExcellonParser(FileSettings()) - p._parse('G00 ') + p._parse_line('G00 ') assert_equal(p.state, 'ROUT') - p._parse('G05 ') + p._parse_line('G05 ') assert_equal(p.state, 'DRILL') def test_parse_version(): p = ExcellonParser(FileSettings()) - p._parse('VER,1 ') + p._parse_line('VER,1 ') assert_equal(p.statements[0].version, 1) - p._parse('VER,2 ') + p._parse_line('VER,2 ') assert_equal(p.statements[1].version, 2) def test_parse_format(): p = ExcellonParser(FileSettings()) - p._parse('FMAT,1 ') + p._parse_line('FMAT,1 ') assert_equal(p.statements[0].format, 1) - p._parse('FMAT,2 ') + p._parse_line('FMAT,2 ') assert_equal(p.statements[1].format, 2) def test_parse_units(): settings = FileSettings(units='inch', zeros='trailing') p = ExcellonParser(settings) - p._parse(';METRIC,LZ') + p._parse_line(';METRIC,LZ') assert_equal(p.units, 'inch') assert_equal(p.zeros, 'trailing') - p._parse('METRIC,LZ') + p._parse_line('METRIC,LZ') assert_equal(p.units, 'metric') assert_equal(p.zeros, 'leading') @@ -160,9 +160,9 @@ def test_parse_incremental_mode(): settings = FileSettings(units='inch', zeros='trailing') p = ExcellonParser(settings) assert_equal(p.notation, 'absolute') - p._parse('ICI,ON ') + p._parse_line('ICI,ON ') assert_equal(p.notation, 'incremental') - p._parse('ICI,OFF ') + p._parse_line('ICI,OFF ') assert_equal(p.notation, 'absolute') @@ -170,29 +170,29 @@ def test_parse_absolute_mode(): settings = FileSettings(units='inch', zeros='trailing') p = ExcellonParser(settings) assert_equal(p.notation, 'absolute') - p._parse('ICI,ON ') + p._parse_line('ICI,ON ') assert_equal(p.notation, 'incremental') - p._parse('G90 ') + p._parse_line('G90 ') assert_equal(p.notation, 'absolute') def test_parse_repeat_hole(): p = ExcellonParser(FileSettings()) p.active_tool = ExcellonTool(FileSettings(), number=8) - p._parse('R03X1.5Y1.5') + p._parse_line('R03X1.5Y1.5') assert_equal(p.statements[0].count, 3) def test_parse_incremental_position(): p = ExcellonParser(FileSettings(notation='incremental')) - p._parse('X01Y01') - p._parse('X01Y01') + p._parse_line('X01Y01') + p._parse_line('X01Y01') assert_equal(p.pos, [2.,2.]) def test_parse_unknown(): p = ExcellonParser(FileSettings()) - p._parse('Not A Valid Statement') + p._parse_line('Not A Valid Statement') assert_equal(p.statements[0].stmt, 'Not A Valid Statement') -- cgit From 52c6d4928a1b5fc65b95cf5b0784a560cec2ca1d Mon Sep 17 00:00:00 2001 From: Garret Fick Date: Sat, 16 Jul 2016 15:49:48 +0800 Subject: Fix most broken tests so that I can safely merge into changes with known expected test result --- gerber/tests/test_excellon.py | 5 +++-- 1 file changed, 3 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 705adc3..afc2917 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -78,8 +78,9 @@ 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,inch_primitives): - assert_equal(m, i) + for m, i in zip(ncdrill.primitives, inch_primitives): + assert_equal(m.position, i.position, '%s not equal to %s' % (m, i)) + assert_equal(m.diameter, i.diameter, '%s not equal to %s' % (m, i)) def test_parser_hole_count(): -- cgit From 8cd842a41a55ab3d8f558a2e3e198beba7da58a1 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Thu, 21 Jan 2016 03:57:44 -0500 Subject: Manually mere rendering changes --- gerber/tests/test_excellon.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gerber/tests/test_excellon.py') diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index cd94b0f..1402938 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -13,6 +13,7 @@ from .tests import * NCDRILL_FILE = os.path.join(os.path.dirname(__file__), 'resources/ncdrill.DRD') + def test_format_detection(): """ Test file type detection """ @@ -75,7 +76,8 @@ def test_conversion(): for statement in ncdrill_inch.statements: statement.to_metric() - for m_tool, i_tool in zip(iter(ncdrill.tools.values()), iter(ncdrill_inch.tools.values())): + 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, inch_primitives): @@ -188,12 +190,10 @@ def test_parse_incremental_position(): p = ExcellonParser(FileSettings(notation='incremental')) p._parse_line('X01Y01') p._parse_line('X01Y01') - assert_equal(p.pos, [2.,2.]) + assert_equal(p.pos, [2., 2.]) def test_parse_unknown(): p = ExcellonParser(FileSettings()) p._parse_line('Not A Valid Statement') assert_equal(p.statements[0].stmt, 'Not A Valid Statement') - - -- cgit