From f98b918634f23cf822b0d054ac4b6a0b790bb760 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Mon, 2 Feb 2015 20:03:26 -0500 Subject: Added some Aperture Macro Primitives. Moved AM primitives to seperate file --- gerber/tests/test_am_statements.py | 77 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 gerber/tests/test_am_statements.py (limited to 'gerber/tests/test_am_statements.py') diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py new file mode 100644 index 0000000..2ba7733 --- /dev/null +++ b/gerber/tests/test_am_statements.py @@ -0,0 +1,77 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +# Author: Hamilton Kibbe + +from .tests import * +from ..am_statements import * + +def test_AMPrimitive_ctor(): + for exposure in ('on', 'off', 'ON', 'OFF'): + for code in (0, 1, 2, 4, 5, 6, 7, 20, 21, 22): + p = AMPrimitive(code, exposure) + assert_equal(p.code, code) + assert_equal(p.exposure, exposure.lower()) + + +def test_AMPrimitive_validation(): + assert_raises(TypeError, AMPrimitive, '1', 'off') + assert_raises(ValueError, AMPrimitive, 0, 'exposed') + assert_raises(ValueError, AMPrimitive, 3, 'off') + + +def test_AMCommentPrimitive_ctor(): + c = AMCommentPrimitive(0, ' This is a comment *') + assert_equal(c.code, 0) + assert_equal(c.comment, 'This is a comment') + + +def test_AMCommentPrimitive_validation(): + assert_raises(ValueError, AMCommentPrimitive, 1, 'This is a comment') + + +def test_AMCommentPrimitive_factory(): + c = AMCommentPrimitive.from_gerber('0 Rectangle with rounded corners. *') + assert_equal(c.code, 0) + assert_equal(c.comment, 'Rectangle with rounded corners.') + + +def test_AMCommentPrimitive_dump(): + c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') + assert_equal(c.to_gerber(), '0 Rectangle with rounded corners. *') + + +def test_AMCirclePrimitive_ctor(): + test_cases = ((1, 'on', 0, (0, 0)), + (1, 'off', 1, (0, 1)), + (1, 'on', 2.5, (0, 2)), + (1, 'off', 5.0, (3, 3))) + for code, exposure, diameter, position in test_cases: + c = AMCirclePrimitive(code, exposure, diameter, position) + assert_equal(c.code, code) + assert_equal(c.exposure, exposure) + assert_equal(c.diameter, diameter) + assert_equal(c.position, position) + + +def test_AMCirclePrimitive_validation(): + assert_raises(ValueError, AMCirclePrimitive, 2, 'on', 0, (0, 0)) + + +def test_AMCirclePrimitive_factory(): + c = AMCirclePrimitive.from_gerber('1,0,5,0,0*') + assert_equal(c.code, 1) + assert_equal(c.exposure, 'off') + assert_equal(c.diameter, 5) + assert_equal(c.position, (0,0)) + + +def test_AMCirclePrimitive_dump(): + c = AMCirclePrimitive(1, 'off', 5, (0, 0)) + assert_equal(c.to_gerber(), '1,0,5,0,0*') + c = AMCirclePrimitive(1, 'on', 5, (0, 0)) + assert_equal(c.to_gerber(), '1,1,5,0,0*') + + + + \ No newline at end of file -- cgit From b0c55082b001a1232fb20bae25390a1514c9e8a9 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Mon, 9 Feb 2015 13:57:15 -0500 Subject: Add aperture macro statement tests --- gerber/tests/test_am_statements.py | 261 ++++++++++++++++++++++++++++++++++++- 1 file changed, 260 insertions(+), 1 deletion(-) (limited to 'gerber/tests/test_am_statements.py') diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py index 2ba7733..696d951 100644 --- a/gerber/tests/test_am_statements.py +++ b/gerber/tests/test_am_statements.py @@ -5,6 +5,7 @@ from .tests import * from ..am_statements import * +from ..am_statements import inch, metric def test_AMPrimitive_ctor(): for exposure in ('on', 'off', 'ON', 'OFF'): @@ -19,6 +20,12 @@ def test_AMPrimitive_validation(): assert_raises(ValueError, AMPrimitive, 0, 'exposed') assert_raises(ValueError, AMPrimitive, 3, 'off') +def test_AMPrimitive_conversion(): + p = AMPrimitive(4, 'on') + assert_raises(NotImplementedError, p.to_inch) + assert_raises(NotImplementedError, p.to_metric) + + def test_AMCommentPrimitive_ctor(): c = AMCommentPrimitive(0, ' This is a comment *') @@ -40,6 +47,19 @@ def test_AMCommentPrimitive_dump(): c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') assert_equal(c.to_gerber(), '0 Rectangle with rounded corners. *') +def test_AMCommentPrimitive_conversion(): + c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') + ci = c + cm = c + ci.to_inch() + cm.to_metric() + assert_equal(c, ci) + assert_equal(c, cm) + +def test_AMCommentPrimitive_string(): + c = AMCommentPrimitive(0, 'Test Comment') + assert_equal(str(c), '') + def test_AMCirclePrimitive_ctor(): test_cases = ((1, 'on', 0, (0, 0)), @@ -72,6 +92,245 @@ def test_AMCirclePrimitive_dump(): c = AMCirclePrimitive(1, 'on', 5, (0, 0)) assert_equal(c.to_gerber(), '1,1,5,0,0*') +def test_AMCirclePrimitive_conversion(): + c = AMCirclePrimitive(1, 'off', 25.4, (25.4, 0)) + c.to_inch() + assert_equal(c.diameter, 1) + assert_equal(c.position, (1, 0)) + + c = AMCirclePrimitive(1, 'off', 1, (1, 0)) + c.to_metric() + assert_equal(c.diameter, 25.4) + assert_equal(c.position, (25.4, 0)) + +def test_AMVectorLinePrimitive_validation(): + assert_raises(ValueError, AMVectorLinePrimitive, 3, 'on', 0.1, (0,0), (3.3, 5.4), 0) + +def test_AMVectorLinePrimitive_factory(): + l = AMVectorLinePrimitive.from_gerber('20,1,0.9,0,0.45,12,0.45,0*') + assert_equal(l.code, 20) + assert_equal(l.exposure, 'on') + assert_equal(l.width, 0.9) + assert_equal(l.start, (0, 0.45)) + assert_equal(l.end, (12, 0.45)) + assert_equal(l.rotation, 0) + +def test_AMVectorLinePrimitive_dump(): + l = AMVectorLinePrimitive.from_gerber('20,1,0.9,0,0.45,12,0.45,0*') + assert_equal(l.to_gerber(), '20,1,0.9,0.0,0.45,12.0,0.45,0.0*') + +def test_AMVectorLinePrimtive_conversion(): + l = AMVectorLinePrimitive(20, 'on', 25.4, (0,0), (25.4, 25.4), 0) + l.to_inch() + assert_equal(l.width, 1) + assert_equal(l.start, (0, 0)) + assert_equal(l.end, (1, 1)) + + l = AMVectorLinePrimitive(20, 'on', 1, (0,0), (1, 1), 0) + l.to_metric() + assert_equal(l.width, 25.4) + assert_equal(l.start, (0, 0)) + assert_equal(l.end, (25.4, 25.4)) + +def test_AMOutlinePrimitive_validation(): + assert_raises(ValueError, AMOutlinePrimitive, 7, 'on', (0,0), [(3.3, 5.4), (4.0, 5.4), (0, 0)], 0) + assert_raises(ValueError, AMOutlinePrimitive, 4, 'on', (0,0), [(3.3, 5.4), (4.0, 5.4), (0, 1)], 0) + +def test_AMOutlinePrimitive_factory(): + o = AMOutlinePrimitive.from_gerber('4,1,3,0,0,3,3,3,0,0,0,0*') + assert_equal(o.code, 4) + assert_equal(o.exposure, 'on') + assert_equal(o.start_point, (0, 0)) + assert_equal(o.points, [(3, 3), (3, 0), (0, 0)]) + assert_equal(o.rotation, 0) + +def test_AMOUtlinePrimitive_dump(): + o = AMOutlinePrimitive(4, 'on', (0, 0), [(3, 3), (3, 0), (0, 0)], 0) + assert_equal(o.to_gerber(), '4,1,3,0,0,3,3,3,0,0,0,0*') + +def test_AMOutlinePrimitive_conversion(): + o = AMOutlinePrimitive(4, 'on', (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) + o.to_inch() + assert_equal(o.start_point, (0, 0)) + assert_equal(o.points, ((1., 1.), (1., 0.), (0., 0.))) + + o = AMOutlinePrimitive(4, 'on', (0, 0), [(1, 1), (1, 0), (0, 0)], 0) + o.to_metric() + assert_equal(o.start_point, (0, 0)) + assert_equal(o.points, ((25.4, 25.4), (25.4, 0), (0, 0))) + + +def test_AMPolygonPrimitive_validation(): + assert_raises(ValueError, AMPolygonPrimitive, 6, 'on', 3, (3.3, 5.4), 3, 0) + assert_raises(ValueError, AMPolygonPrimitive, 5, 'on', 2, (3.3, 5.4), 3, 0) + assert_raises(ValueError, AMPolygonPrimitive, 5, 'on', 13, (3.3, 5.4), 3, 0) + +def test_AMPolygonPrimitive_factory(): + p = AMPolygonPrimitive.from_gerber('5,1,3,3.3,5.4,3,0') + assert_equal(p.code, 5) + assert_equal(p.exposure, 'on') + assert_equal(p.vertices, 3) + assert_equal(p.position, (3.3, 5.4)) + assert_equal(p.diameter, 3) + assert_equal(p.rotation, 0) + +def test_AMPolygonPrimitive_dump(): + p = AMPolygonPrimitive(5, 'on', 3, (3.3, 5.4), 3, 0) + assert_equal(p.to_gerber(), '5,1,3,3.3,5.4,3,0*') + +def test_AMPolygonPrimitive_conversion(): + p = AMPolygonPrimitive(5, 'off', 3, (25.4, 0), 25.4, 0) + p.to_inch() + assert_equal(p.diameter, 1) + assert_equal(p.position, (1, 0)) + + p = AMPolygonPrimitive(5, 'off', 3, (1, 0), 1, 0) + p.to_metric() + assert_equal(p.diameter, 25.4) + assert_equal(p.position, (25.4, 0)) + + +def test_AMMoirePrimitive_validation(): + assert_raises(ValueError, AMMoirePrimitive, 7, (0, 0), 5.1, 0.2, 0.4, 6, 0.1, 6.1, 0) + +def test_AMMoirePrimitive_factory(): + m = AMMoirePrimitive.from_gerber('6,0,0,5,0.5,0.5,2,0.1,6,0*') + assert_equal(m.code, 6) + assert_equal(m.position, (0, 0)) + assert_equal(m.diameter, 5) + assert_equal(m.ring_thickness, 0.5) + assert_equal(m.gap, 0.5) + assert_equal(m.max_rings, 2) + assert_equal(m.crosshair_thickness, 0.1) + assert_equal(m.crosshair_length, 6) + assert_equal(m.rotation, 0) + +def test_AMMoirePrimitive_dump(): + m = AMMoirePrimitive.from_gerber('6,0,0,5,0.5,0.5,2,0.1,6,0*') + assert_equal(m.to_gerber(), '6,0,0,5.0,0.5,0.5,2,0.1,6.0,0.0*') + +def test_AMMoirePrimitive_conversion(): + m = AMMoirePrimitive(6, (25.4, 25.4), 25.4, 25.4, 25.4, 6, 25.4, 25.4, 0) + m.to_inch() + assert_equal(m.position, (1., 1.)) + assert_equal(m.diameter, 1.) + assert_equal(m.ring_thickness, 1.) + assert_equal(m.gap, 1.) + assert_equal(m.crosshair_thickness, 1.) + assert_equal(m.crosshair_length, 1.) + + m = AMMoirePrimitive(6, (1, 1), 1, 1, 1, 6, 1, 1, 0) + m.to_metric() + assert_equal(m.position, (25.4, 25.4)) + assert_equal(m.diameter, 25.4) + assert_equal(m.ring_thickness, 25.4) + assert_equal(m.gap, 25.4) + assert_equal(m.crosshair_thickness, 25.4) + assert_equal(m.crosshair_length, 25.4) + +def test_AMThermalPrimitive_validation(): + assert_raises(ValueError, AMThermalPrimitive, 8, (0.0, 0.0), 7, 5, 0.2) + assert_raises(TypeError, AMThermalPrimitive, 7, (0.0, '0'), 7, 5, 0.2) + +def test_AMThermalPrimitive_factory(): + t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2*') + assert_equal(t.code, 7) + assert_equal(t.position, (0, 0)) + assert_equal(t.outer_diameter, 7) + assert_equal(t.inner_diameter, 6) + assert_equal(t.gap, 0.2) + +def test_AMThermalPrimitive_dump(): + t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2*') + assert_equal(t.to_gerber(), '7,0,0,7.0,6.0,0.2*') + +def test_AMThermalPrimitive_conversion(): + t = AMThermalPrimitive(7, (25.4, 25.4), 25.4, 25.4, 25.4) + t.to_inch() + assert_equal(t.position, (1., 1.)) + assert_equal(t.outer_diameter, 1.) + assert_equal(t.inner_diameter, 1.) + assert_equal(t.gap, 1.) + + t = AMThermalPrimitive(7, (1, 1), 1, 1, 1) + t.to_metric() + assert_equal(t.position, (25.4, 25.4)) + assert_equal(t.outer_diameter, 25.4) + assert_equal(t.inner_diameter, 25.4) + assert_equal(t.gap, 25.4) + + +def test_AMCenterLinePrimitive_validation(): + assert_raises(ValueError, AMCenterLinePrimitive, 22, 1, 0.2, 0.5, (0, 0), 0) + +def test_AMCenterLinePrimtive_factory(): + l = AMCenterLinePrimitive.from_gerber('21,1,6.8,1.2,3.4,0.6,0*') + assert_equal(l.code, 21) + assert_equal(l.exposure, 'on') + assert_equal(l.width, 6.8) + assert_equal(l.height, 1.2) + assert_equal(l.center, (3.4, 0.6)) + assert_equal(l.rotation, 0) + +def test_AMCenterLinePrimitive_dump(): + l = AMCenterLinePrimitive.from_gerber('21,1,6.8,1.2,3.4,0.6,0*') + assert_equal(l.to_gerber(), '21,1,6.8,1.2,3.4,0.6,0.0*') + +def test_AMCenterLinePrimitive_conversion(): + l = AMCenterLinePrimitive(21, 'on', 25.4, 25.4, (25.4, 25.4), 0) + l.to_inch() + assert_equal(l.width, 1.) + assert_equal(l.height, 1.) + assert_equal(l.center, (1., 1.)) + + l = AMCenterLinePrimitive(21, 'on', 1, 1, (1, 1), 0) + l.to_metric() + assert_equal(l.width, 25.4) + assert_equal(l.height, 25.4) + assert_equal(l.center, (25.4, 25.4)) + +def test_AMLowerLeftLinePrimitive_validation(): + assert_raises(ValueError, AMLowerLeftLinePrimitive, 23, 1, 0.2, 0.5, (0, 0), 0) + +def test_AMLowerLeftLinePrimtive_factory(): + l = AMLowerLeftLinePrimitive.from_gerber('22,1,6.8,1.2,3.4,0.6,0*') + assert_equal(l.code, 22) + assert_equal(l.exposure, 'on') + assert_equal(l.width, 6.8) + assert_equal(l.height, 1.2) + assert_equal(l.lower_left, (3.4, 0.6)) + assert_equal(l.rotation, 0) + +def test_AMLowerLeftLinePrimitive_dump(): + l = AMLowerLeftLinePrimitive.from_gerber('22,1,6.8,1.2,3.4,0.6,0*') + assert_equal(l.to_gerber(), '22,1,6.8,1.2,3.4,0.6,0.0*') + +def test_AMLowerLeftLinePrimitive_conversion(): + l = AMLowerLeftLinePrimitive(22, 'on', 25.4, 25.4, (25.4, 25.4), 0) + l.to_inch() + assert_equal(l.width, 1.) + assert_equal(l.height, 1.) + assert_equal(l.lower_left, (1., 1.)) + + l = AMLowerLeftLinePrimitive(22, 'on', 1, 1, (1, 1), 0) + l.to_metric() + assert_equal(l.width, 25.4) + assert_equal(l.height, 25.4) + assert_equal(l.lower_left, (25.4, 25.4)) + +def test_AMUnsupportPrimitive(): + u = AMUnsupportPrimitive.from_gerber('Test') + assert_equal(u.primitive, 'Test') + u = AMUnsupportPrimitive('Test') + assert_equal(u.to_gerber(), 'Test') + + + +def test_inch(): + assert_equal(inch(25.4), 1) + +def test_metric(): + assert_equal(metric(1), 25.4) + - \ No newline at end of file -- 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_am_statements.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gerber/tests/test_am_statements.py') diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py index 696d951..0cee13d 100644 --- a/gerber/tests/test_am_statements.py +++ b/gerber/tests/test_am_statements.py @@ -324,6 +324,11 @@ def test_AMUnsupportPrimitive(): u = AMUnsupportPrimitive('Test') assert_equal(u.to_gerber(), 'Test') +def test_AMUnsupportPrimitive_smoketest(): + u = AMUnsupportPrimitive.from_gerber('Test') + u.to_inch() + u.to_metric() + def test_inch(): -- cgit From 5476da8aa3f4ee424f56f4f2491e7af1c4b7b758 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Thu, 21 Jan 2016 03:57:44 -0500 Subject: Fix a bunch of rendering bugs. - 'clear' polarity primitives no longer erase background - Added aperture macro support for polygons - Added aperture macro rendring support - Renderer now creates a new surface for each layer and merges them instead of working directly on a single surface - Updated examples accordingly --- gerber/tests/test_am_statements.py | 65 +++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 15 deletions(-) (limited to 'gerber/tests/test_am_statements.py') diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py index 0cee13d..8c95e6a 100644 --- a/gerber/tests/test_am_statements.py +++ b/gerber/tests/test_am_statements.py @@ -7,6 +7,7 @@ from .tests import * from ..am_statements import * from ..am_statements import inch, metric + def test_AMPrimitive_ctor(): for exposure in ('on', 'off', 'ON', 'OFF'): for code in (0, 1, 2, 4, 5, 6, 7, 20, 21, 22): @@ -20,13 +21,13 @@ def test_AMPrimitive_validation(): assert_raises(ValueError, AMPrimitive, 0, 'exposed') assert_raises(ValueError, AMPrimitive, 3, 'off') + def test_AMPrimitive_conversion(): p = AMPrimitive(4, 'on') assert_raises(NotImplementedError, p.to_inch) assert_raises(NotImplementedError, p.to_metric) - def test_AMCommentPrimitive_ctor(): c = AMCommentPrimitive(0, ' This is a comment *') assert_equal(c.code, 0) @@ -47,6 +48,7 @@ def test_AMCommentPrimitive_dump(): c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') assert_equal(c.to_gerber(), '0 Rectangle with rounded corners. *') + def test_AMCommentPrimitive_conversion(): c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') ci = c @@ -56,6 +58,7 @@ def test_AMCommentPrimitive_conversion(): assert_equal(c, ci) assert_equal(c, cm) + def test_AMCommentPrimitive_string(): c = AMCommentPrimitive(0, 'Test Comment') assert_equal(str(c), '') @@ -83,7 +86,7 @@ def test_AMCirclePrimitive_factory(): assert_equal(c.code, 1) assert_equal(c.exposure, 'off') assert_equal(c.diameter, 5) - assert_equal(c.position, (0,0)) + assert_equal(c.position, (0, 0)) def test_AMCirclePrimitive_dump(): @@ -92,6 +95,7 @@ def test_AMCirclePrimitive_dump(): c = AMCirclePrimitive(1, 'on', 5, (0, 0)) assert_equal(c.to_gerber(), '1,1,5,0,0*') + def test_AMCirclePrimitive_conversion(): c = AMCirclePrimitive(1, 'off', 25.4, (25.4, 0)) c.to_inch() @@ -103,8 +107,11 @@ def test_AMCirclePrimitive_conversion(): assert_equal(c.diameter, 25.4) assert_equal(c.position, (25.4, 0)) + def test_AMVectorLinePrimitive_validation(): - assert_raises(ValueError, AMVectorLinePrimitive, 3, 'on', 0.1, (0,0), (3.3, 5.4), 0) + assert_raises(ValueError, AMVectorLinePrimitive, + 3, 'on', 0.1, (0, 0), (3.3, 5.4), 0) + def test_AMVectorLinePrimitive_factory(): l = AMVectorLinePrimitive.from_gerber('20,1,0.9,0,0.45,12,0.45,0*') @@ -115,26 +122,32 @@ def test_AMVectorLinePrimitive_factory(): assert_equal(l.end, (12, 0.45)) assert_equal(l.rotation, 0) + def test_AMVectorLinePrimitive_dump(): l = AMVectorLinePrimitive.from_gerber('20,1,0.9,0,0.45,12,0.45,0*') assert_equal(l.to_gerber(), '20,1,0.9,0.0,0.45,12.0,0.45,0.0*') + def test_AMVectorLinePrimtive_conversion(): - l = AMVectorLinePrimitive(20, 'on', 25.4, (0,0), (25.4, 25.4), 0) + l = AMVectorLinePrimitive(20, 'on', 25.4, (0, 0), (25.4, 25.4), 0) l.to_inch() assert_equal(l.width, 1) assert_equal(l.start, (0, 0)) assert_equal(l.end, (1, 1)) - l = AMVectorLinePrimitive(20, 'on', 1, (0,0), (1, 1), 0) + l = AMVectorLinePrimitive(20, 'on', 1, (0, 0), (1, 1), 0) l.to_metric() assert_equal(l.width, 25.4) assert_equal(l.start, (0, 0)) assert_equal(l.end, (25.4, 25.4)) + def test_AMOutlinePrimitive_validation(): - assert_raises(ValueError, AMOutlinePrimitive, 7, 'on', (0,0), [(3.3, 5.4), (4.0, 5.4), (0, 0)], 0) - assert_raises(ValueError, AMOutlinePrimitive, 4, 'on', (0,0), [(3.3, 5.4), (4.0, 5.4), (0, 1)], 0) + assert_raises(ValueError, AMOutlinePrimitive, 7, 'on', + (0, 0), [(3.3, 5.4), (4.0, 5.4), (0, 0)], 0) + assert_raises(ValueError, AMOutlinePrimitive, 4, 'on', + (0, 0), [(3.3, 5.4), (4.0, 5.4), (0, 1)], 0) + def test_AMOutlinePrimitive_factory(): o = AMOutlinePrimitive.from_gerber('4,1,3,0,0,3,3,3,0,0,0,0*') @@ -144,12 +157,15 @@ def test_AMOutlinePrimitive_factory(): assert_equal(o.points, [(3, 3), (3, 0), (0, 0)]) assert_equal(o.rotation, 0) + def test_AMOUtlinePrimitive_dump(): o = AMOutlinePrimitive(4, 'on', (0, 0), [(3, 3), (3, 0), (0, 0)], 0) assert_equal(o.to_gerber(), '4,1,3,0,0,3,3,3,0,0,0,0*') + def test_AMOutlinePrimitive_conversion(): - o = AMOutlinePrimitive(4, 'on', (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) + o = AMOutlinePrimitive( + 4, 'on', (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) o.to_inch() assert_equal(o.start_point, (0, 0)) assert_equal(o.points, ((1., 1.), (1., 0.), (0., 0.))) @@ -165,6 +181,7 @@ def test_AMPolygonPrimitive_validation(): assert_raises(ValueError, AMPolygonPrimitive, 5, 'on', 2, (3.3, 5.4), 3, 0) assert_raises(ValueError, AMPolygonPrimitive, 5, 'on', 13, (3.3, 5.4), 3, 0) + def test_AMPolygonPrimitive_factory(): p = AMPolygonPrimitive.from_gerber('5,1,3,3.3,5.4,3,0') assert_equal(p.code, 5) @@ -174,10 +191,12 @@ def test_AMPolygonPrimitive_factory(): assert_equal(p.diameter, 3) assert_equal(p.rotation, 0) + def test_AMPolygonPrimitive_dump(): p = AMPolygonPrimitive(5, 'on', 3, (3.3, 5.4), 3, 0) assert_equal(p.to_gerber(), '5,1,3,3.3,5.4,3,0*') + def test_AMPolygonPrimitive_conversion(): p = AMPolygonPrimitive(5, 'off', 3, (25.4, 0), 25.4, 0) p.to_inch() @@ -191,7 +210,9 @@ def test_AMPolygonPrimitive_conversion(): def test_AMMoirePrimitive_validation(): - assert_raises(ValueError, AMMoirePrimitive, 7, (0, 0), 5.1, 0.2, 0.4, 6, 0.1, 6.1, 0) + assert_raises(ValueError, AMMoirePrimitive, 7, + (0, 0), 5.1, 0.2, 0.4, 6, 0.1, 6.1, 0) + def test_AMMoirePrimitive_factory(): m = AMMoirePrimitive.from_gerber('6,0,0,5,0.5,0.5,2,0.1,6,0*') @@ -205,10 +226,12 @@ def test_AMMoirePrimitive_factory(): assert_equal(m.crosshair_length, 6) assert_equal(m.rotation, 0) + def test_AMMoirePrimitive_dump(): m = AMMoirePrimitive.from_gerber('6,0,0,5,0.5,0.5,2,0.1,6,0*') assert_equal(m.to_gerber(), '6,0,0,5.0,0.5,0.5,2,0.1,6.0,0.0*') + def test_AMMoirePrimitive_conversion(): m = AMMoirePrimitive(6, (25.4, 25.4), 25.4, 25.4, 25.4, 6, 25.4, 25.4, 0) m.to_inch() @@ -228,10 +251,12 @@ def test_AMMoirePrimitive_conversion(): assert_equal(m.crosshair_thickness, 25.4) assert_equal(m.crosshair_length, 25.4) + def test_AMThermalPrimitive_validation(): assert_raises(ValueError, AMThermalPrimitive, 8, (0.0, 0.0), 7, 5, 0.2) assert_raises(TypeError, AMThermalPrimitive, 7, (0.0, '0'), 7, 5, 0.2) + def test_AMThermalPrimitive_factory(): t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2*') assert_equal(t.code, 7) @@ -240,10 +265,12 @@ def test_AMThermalPrimitive_factory(): assert_equal(t.inner_diameter, 6) assert_equal(t.gap, 0.2) + def test_AMThermalPrimitive_dump(): t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2*') assert_equal(t.to_gerber(), '7,0,0,7.0,6.0,0.2*') + def test_AMThermalPrimitive_conversion(): t = AMThermalPrimitive(7, (25.4, 25.4), 25.4, 25.4, 25.4) t.to_inch() @@ -261,7 +288,9 @@ def test_AMThermalPrimitive_conversion(): def test_AMCenterLinePrimitive_validation(): - assert_raises(ValueError, AMCenterLinePrimitive, 22, 1, 0.2, 0.5, (0, 0), 0) + assert_raises(ValueError, AMCenterLinePrimitive, + 22, 1, 0.2, 0.5, (0, 0), 0) + def test_AMCenterLinePrimtive_factory(): l = AMCenterLinePrimitive.from_gerber('21,1,6.8,1.2,3.4,0.6,0*') @@ -272,10 +301,12 @@ def test_AMCenterLinePrimtive_factory(): assert_equal(l.center, (3.4, 0.6)) assert_equal(l.rotation, 0) + def test_AMCenterLinePrimitive_dump(): l = AMCenterLinePrimitive.from_gerber('21,1,6.8,1.2,3.4,0.6,0*') assert_equal(l.to_gerber(), '21,1,6.8,1.2,3.4,0.6,0.0*') + def test_AMCenterLinePrimitive_conversion(): l = AMCenterLinePrimitive(21, 'on', 25.4, 25.4, (25.4, 25.4), 0) l.to_inch() @@ -289,8 +320,11 @@ def test_AMCenterLinePrimitive_conversion(): assert_equal(l.height, 25.4) assert_equal(l.center, (25.4, 25.4)) + def test_AMLowerLeftLinePrimitive_validation(): - assert_raises(ValueError, AMLowerLeftLinePrimitive, 23, 1, 0.2, 0.5, (0, 0), 0) + assert_raises(ValueError, AMLowerLeftLinePrimitive, + 23, 1, 0.2, 0.5, (0, 0), 0) + def test_AMLowerLeftLinePrimtive_factory(): l = AMLowerLeftLinePrimitive.from_gerber('22,1,6.8,1.2,3.4,0.6,0*') @@ -301,10 +335,12 @@ def test_AMLowerLeftLinePrimtive_factory(): assert_equal(l.lower_left, (3.4, 0.6)) assert_equal(l.rotation, 0) + def test_AMLowerLeftLinePrimitive_dump(): l = AMLowerLeftLinePrimitive.from_gerber('22,1,6.8,1.2,3.4,0.6,0*') assert_equal(l.to_gerber(), '22,1,6.8,1.2,3.4,0.6,0.0*') + def test_AMLowerLeftLinePrimitive_conversion(): l = AMLowerLeftLinePrimitive(22, 'on', 25.4, 25.4, (25.4, 25.4), 0) l.to_inch() @@ -318,24 +354,23 @@ def test_AMLowerLeftLinePrimitive_conversion(): assert_equal(l.height, 25.4) assert_equal(l.lower_left, (25.4, 25.4)) + def test_AMUnsupportPrimitive(): u = AMUnsupportPrimitive.from_gerber('Test') assert_equal(u.primitive, 'Test') u = AMUnsupportPrimitive('Test') assert_equal(u.to_gerber(), 'Test') + def test_AMUnsupportPrimitive_smoketest(): u = AMUnsupportPrimitive.from_gerber('Test') u.to_inch() u.to_metric() - def test_inch(): assert_equal(inch(25.4), 1) + def test_metric(): assert_equal(metric(1), 25.4) - - - -- 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_am_statements.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'gerber/tests/test_am_statements.py') diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py index 0cee13d..39324e5 100644 --- a/gerber/tests/test_am_statements.py +++ b/gerber/tests/test_am_statements.py @@ -146,7 +146,9 @@ def test_AMOutlinePrimitive_factory(): def test_AMOUtlinePrimitive_dump(): o = AMOutlinePrimitive(4, 'on', (0, 0), [(3, 3), (3, 0), (0, 0)], 0) - assert_equal(o.to_gerber(), '4,1,3,0,0,3,3,3,0,0,0,0*') + # New lines don't matter for Gerber, but we insert them to make it easier to remove + # For test purposes we can ignore them + assert_equal(o.to_gerber().replace('\n', ''), '4,1,3,0,0,3,3,3,0,0,0,0*') def test_AMOutlinePrimitive_conversion(): o = AMOutlinePrimitive(4, 'on', (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) @@ -229,30 +231,31 @@ def test_AMMoirePrimitive_conversion(): assert_equal(m.crosshair_length, 25.4) def test_AMThermalPrimitive_validation(): - assert_raises(ValueError, AMThermalPrimitive, 8, (0.0, 0.0), 7, 5, 0.2) - assert_raises(TypeError, AMThermalPrimitive, 7, (0.0, '0'), 7, 5, 0.2) + assert_raises(ValueError, AMThermalPrimitive, 8, (0.0, 0.0), 7, 5, 0.2, 0.0) + assert_raises(TypeError, AMThermalPrimitive, 7, (0.0, '0'), 7, 5, 0.2, 0.0) def test_AMThermalPrimitive_factory(): - t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2*') + t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2,45*') assert_equal(t.code, 7) assert_equal(t.position, (0, 0)) assert_equal(t.outer_diameter, 7) assert_equal(t.inner_diameter, 6) assert_equal(t.gap, 0.2) + assert_equal(t.rotation, 45) def test_AMThermalPrimitive_dump(): - t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2*') - assert_equal(t.to_gerber(), '7,0,0,7.0,6.0,0.2*') + t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2,30*') + assert_equal(t.to_gerber(), '7,0,0,7.0,6.0,0.2,30.0*') def test_AMThermalPrimitive_conversion(): - t = AMThermalPrimitive(7, (25.4, 25.4), 25.4, 25.4, 25.4) + t = AMThermalPrimitive(7, (25.4, 25.4), 25.4, 25.4, 25.4, 0.0) t.to_inch() assert_equal(t.position, (1., 1.)) assert_equal(t.outer_diameter, 1.) assert_equal(t.inner_diameter, 1.) assert_equal(t.gap, 1.) - t = AMThermalPrimitive(7, (1, 1), 1, 1, 1) + t = AMThermalPrimitive(7, (1, 1), 1, 1, 1, 0) t.to_metric() assert_equal(t.position, (25.4, 25.4)) assert_equal(t.outer_diameter, 25.4) -- 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_am_statements.py | 65 +++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 15 deletions(-) (limited to 'gerber/tests/test_am_statements.py') diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py index 39324e5..c5ae6ae 100644 --- a/gerber/tests/test_am_statements.py +++ b/gerber/tests/test_am_statements.py @@ -7,6 +7,7 @@ from .tests import * from ..am_statements import * from ..am_statements import inch, metric + def test_AMPrimitive_ctor(): for exposure in ('on', 'off', 'ON', 'OFF'): for code in (0, 1, 2, 4, 5, 6, 7, 20, 21, 22): @@ -20,13 +21,13 @@ def test_AMPrimitive_validation(): assert_raises(ValueError, AMPrimitive, 0, 'exposed') assert_raises(ValueError, AMPrimitive, 3, 'off') + def test_AMPrimitive_conversion(): p = AMPrimitive(4, 'on') assert_raises(NotImplementedError, p.to_inch) assert_raises(NotImplementedError, p.to_metric) - def test_AMCommentPrimitive_ctor(): c = AMCommentPrimitive(0, ' This is a comment *') assert_equal(c.code, 0) @@ -47,6 +48,7 @@ def test_AMCommentPrimitive_dump(): c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') assert_equal(c.to_gerber(), '0 Rectangle with rounded corners. *') + def test_AMCommentPrimitive_conversion(): c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') ci = c @@ -56,6 +58,7 @@ def test_AMCommentPrimitive_conversion(): assert_equal(c, ci) assert_equal(c, cm) + def test_AMCommentPrimitive_string(): c = AMCommentPrimitive(0, 'Test Comment') assert_equal(str(c), '') @@ -83,7 +86,7 @@ def test_AMCirclePrimitive_factory(): assert_equal(c.code, 1) assert_equal(c.exposure, 'off') assert_equal(c.diameter, 5) - assert_equal(c.position, (0,0)) + assert_equal(c.position, (0, 0)) def test_AMCirclePrimitive_dump(): @@ -92,6 +95,7 @@ def test_AMCirclePrimitive_dump(): c = AMCirclePrimitive(1, 'on', 5, (0, 0)) assert_equal(c.to_gerber(), '1,1,5,0,0*') + def test_AMCirclePrimitive_conversion(): c = AMCirclePrimitive(1, 'off', 25.4, (25.4, 0)) c.to_inch() @@ -103,8 +107,11 @@ def test_AMCirclePrimitive_conversion(): assert_equal(c.diameter, 25.4) assert_equal(c.position, (25.4, 0)) + def test_AMVectorLinePrimitive_validation(): - assert_raises(ValueError, AMVectorLinePrimitive, 3, 'on', 0.1, (0,0), (3.3, 5.4), 0) + assert_raises(ValueError, AMVectorLinePrimitive, + 3, 'on', 0.1, (0, 0), (3.3, 5.4), 0) + def test_AMVectorLinePrimitive_factory(): l = AMVectorLinePrimitive.from_gerber('20,1,0.9,0,0.45,12,0.45,0*') @@ -115,26 +122,32 @@ def test_AMVectorLinePrimitive_factory(): assert_equal(l.end, (12, 0.45)) assert_equal(l.rotation, 0) + def test_AMVectorLinePrimitive_dump(): l = AMVectorLinePrimitive.from_gerber('20,1,0.9,0,0.45,12,0.45,0*') assert_equal(l.to_gerber(), '20,1,0.9,0.0,0.45,12.0,0.45,0.0*') + def test_AMVectorLinePrimtive_conversion(): - l = AMVectorLinePrimitive(20, 'on', 25.4, (0,0), (25.4, 25.4), 0) + l = AMVectorLinePrimitive(20, 'on', 25.4, (0, 0), (25.4, 25.4), 0) l.to_inch() assert_equal(l.width, 1) assert_equal(l.start, (0, 0)) assert_equal(l.end, (1, 1)) - l = AMVectorLinePrimitive(20, 'on', 1, (0,0), (1, 1), 0) + l = AMVectorLinePrimitive(20, 'on', 1, (0, 0), (1, 1), 0) l.to_metric() assert_equal(l.width, 25.4) assert_equal(l.start, (0, 0)) assert_equal(l.end, (25.4, 25.4)) + def test_AMOutlinePrimitive_validation(): - assert_raises(ValueError, AMOutlinePrimitive, 7, 'on', (0,0), [(3.3, 5.4), (4.0, 5.4), (0, 0)], 0) - assert_raises(ValueError, AMOutlinePrimitive, 4, 'on', (0,0), [(3.3, 5.4), (4.0, 5.4), (0, 1)], 0) + assert_raises(ValueError, AMOutlinePrimitive, 7, 'on', + (0, 0), [(3.3, 5.4), (4.0, 5.4), (0, 0)], 0) + assert_raises(ValueError, AMOutlinePrimitive, 4, 'on', + (0, 0), [(3.3, 5.4), (4.0, 5.4), (0, 1)], 0) + def test_AMOutlinePrimitive_factory(): o = AMOutlinePrimitive.from_gerber('4,1,3,0,0,3,3,3,0,0,0,0*') @@ -144,14 +157,17 @@ def test_AMOutlinePrimitive_factory(): assert_equal(o.points, [(3, 3), (3, 0), (0, 0)]) assert_equal(o.rotation, 0) + def test_AMOUtlinePrimitive_dump(): o = AMOutlinePrimitive(4, 'on', (0, 0), [(3, 3), (3, 0), (0, 0)], 0) # New lines don't matter for Gerber, but we insert them to make it easier to remove # For test purposes we can ignore them assert_equal(o.to_gerber().replace('\n', ''), '4,1,3,0,0,3,3,3,0,0,0,0*') + def test_AMOutlinePrimitive_conversion(): - o = AMOutlinePrimitive(4, 'on', (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) + o = AMOutlinePrimitive( + 4, 'on', (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) o.to_inch() assert_equal(o.start_point, (0, 0)) assert_equal(o.points, ((1., 1.), (1., 0.), (0., 0.))) @@ -167,6 +183,7 @@ def test_AMPolygonPrimitive_validation(): assert_raises(ValueError, AMPolygonPrimitive, 5, 'on', 2, (3.3, 5.4), 3, 0) assert_raises(ValueError, AMPolygonPrimitive, 5, 'on', 13, (3.3, 5.4), 3, 0) + def test_AMPolygonPrimitive_factory(): p = AMPolygonPrimitive.from_gerber('5,1,3,3.3,5.4,3,0') assert_equal(p.code, 5) @@ -176,10 +193,12 @@ def test_AMPolygonPrimitive_factory(): assert_equal(p.diameter, 3) assert_equal(p.rotation, 0) + def test_AMPolygonPrimitive_dump(): p = AMPolygonPrimitive(5, 'on', 3, (3.3, 5.4), 3, 0) assert_equal(p.to_gerber(), '5,1,3,3.3,5.4,3,0*') + def test_AMPolygonPrimitive_conversion(): p = AMPolygonPrimitive(5, 'off', 3, (25.4, 0), 25.4, 0) p.to_inch() @@ -193,7 +212,9 @@ def test_AMPolygonPrimitive_conversion(): def test_AMMoirePrimitive_validation(): - assert_raises(ValueError, AMMoirePrimitive, 7, (0, 0), 5.1, 0.2, 0.4, 6, 0.1, 6.1, 0) + assert_raises(ValueError, AMMoirePrimitive, 7, + (0, 0), 5.1, 0.2, 0.4, 6, 0.1, 6.1, 0) + def test_AMMoirePrimitive_factory(): m = AMMoirePrimitive.from_gerber('6,0,0,5,0.5,0.5,2,0.1,6,0*') @@ -207,10 +228,12 @@ def test_AMMoirePrimitive_factory(): assert_equal(m.crosshair_length, 6) assert_equal(m.rotation, 0) + def test_AMMoirePrimitive_dump(): m = AMMoirePrimitive.from_gerber('6,0,0,5,0.5,0.5,2,0.1,6,0*') assert_equal(m.to_gerber(), '6,0,0,5.0,0.5,0.5,2,0.1,6.0,0.0*') + def test_AMMoirePrimitive_conversion(): m = AMMoirePrimitive(6, (25.4, 25.4), 25.4, 25.4, 25.4, 6, 25.4, 25.4, 0) m.to_inch() @@ -230,10 +253,12 @@ def test_AMMoirePrimitive_conversion(): assert_equal(m.crosshair_thickness, 25.4) assert_equal(m.crosshair_length, 25.4) + def test_AMThermalPrimitive_validation(): assert_raises(ValueError, AMThermalPrimitive, 8, (0.0, 0.0), 7, 5, 0.2, 0.0) assert_raises(TypeError, AMThermalPrimitive, 7, (0.0, '0'), 7, 5, 0.2, 0.0) + def test_AMThermalPrimitive_factory(): t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2,45*') assert_equal(t.code, 7) @@ -243,10 +268,12 @@ def test_AMThermalPrimitive_factory(): assert_equal(t.gap, 0.2) assert_equal(t.rotation, 45) + def test_AMThermalPrimitive_dump(): t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2,30*') assert_equal(t.to_gerber(), '7,0,0,7.0,6.0,0.2,30.0*') + def test_AMThermalPrimitive_conversion(): t = AMThermalPrimitive(7, (25.4, 25.4), 25.4, 25.4, 25.4, 0.0) t.to_inch() @@ -264,7 +291,9 @@ def test_AMThermalPrimitive_conversion(): def test_AMCenterLinePrimitive_validation(): - assert_raises(ValueError, AMCenterLinePrimitive, 22, 1, 0.2, 0.5, (0, 0), 0) + assert_raises(ValueError, AMCenterLinePrimitive, + 22, 1, 0.2, 0.5, (0, 0), 0) + def test_AMCenterLinePrimtive_factory(): l = AMCenterLinePrimitive.from_gerber('21,1,6.8,1.2,3.4,0.6,0*') @@ -275,10 +304,12 @@ def test_AMCenterLinePrimtive_factory(): assert_equal(l.center, (3.4, 0.6)) assert_equal(l.rotation, 0) + def test_AMCenterLinePrimitive_dump(): l = AMCenterLinePrimitive.from_gerber('21,1,6.8,1.2,3.4,0.6,0*') assert_equal(l.to_gerber(), '21,1,6.8,1.2,3.4,0.6,0.0*') + def test_AMCenterLinePrimitive_conversion(): l = AMCenterLinePrimitive(21, 'on', 25.4, 25.4, (25.4, 25.4), 0) l.to_inch() @@ -292,8 +323,11 @@ def test_AMCenterLinePrimitive_conversion(): assert_equal(l.height, 25.4) assert_equal(l.center, (25.4, 25.4)) + def test_AMLowerLeftLinePrimitive_validation(): - assert_raises(ValueError, AMLowerLeftLinePrimitive, 23, 1, 0.2, 0.5, (0, 0), 0) + assert_raises(ValueError, AMLowerLeftLinePrimitive, + 23, 1, 0.2, 0.5, (0, 0), 0) + def test_AMLowerLeftLinePrimtive_factory(): l = AMLowerLeftLinePrimitive.from_gerber('22,1,6.8,1.2,3.4,0.6,0*') @@ -304,10 +338,12 @@ def test_AMLowerLeftLinePrimtive_factory(): assert_equal(l.lower_left, (3.4, 0.6)) assert_equal(l.rotation, 0) + def test_AMLowerLeftLinePrimitive_dump(): l = AMLowerLeftLinePrimitive.from_gerber('22,1,6.8,1.2,3.4,0.6,0*') assert_equal(l.to_gerber(), '22,1,6.8,1.2,3.4,0.6,0.0*') + def test_AMLowerLeftLinePrimitive_conversion(): l = AMLowerLeftLinePrimitive(22, 'on', 25.4, 25.4, (25.4, 25.4), 0) l.to_inch() @@ -321,24 +357,23 @@ def test_AMLowerLeftLinePrimitive_conversion(): assert_equal(l.height, 25.4) assert_equal(l.lower_left, (25.4, 25.4)) + def test_AMUnsupportPrimitive(): u = AMUnsupportPrimitive.from_gerber('Test') assert_equal(u.primitive, 'Test') u = AMUnsupportPrimitive('Test') assert_equal(u.to_gerber(), 'Test') + def test_AMUnsupportPrimitive_smoketest(): u = AMUnsupportPrimitive.from_gerber('Test') u.to_inch() u.to_metric() - def test_inch(): assert_equal(inch(25.4), 1) + def test_metric(): assert_equal(metric(1), 25.4) - - - -- cgit From 5af19af190c1fb0f0c5be029d46d63e657dde4d9 Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Thu, 21 Jan 2016 03:57:44 -0500 Subject: Commit partial merge so I can work on the plane --- gerber/tests/test_am_statements.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gerber/tests/test_am_statements.py') diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py index c5ae6ae..98a7332 100644 --- a/gerber/tests/test_am_statements.py +++ b/gerber/tests/test_am_statements.py @@ -165,6 +165,7 @@ def test_AMOUtlinePrimitive_dump(): assert_equal(o.to_gerber().replace('\n', ''), '4,1,3,0,0,3,3,3,0,0,0,0*') + def test_AMOutlinePrimitive_conversion(): o = AMOutlinePrimitive( 4, 'on', (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) @@ -259,6 +260,7 @@ def test_AMThermalPrimitive_validation(): assert_raises(TypeError, AMThermalPrimitive, 7, (0.0, '0'), 7, 5, 0.2, 0.0) + def test_AMThermalPrimitive_factory(): t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2,45*') assert_equal(t.code, 7) @@ -269,11 +271,13 @@ def test_AMThermalPrimitive_factory(): assert_equal(t.rotation, 45) + def test_AMThermalPrimitive_dump(): t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2,30*') assert_equal(t.to_gerber(), '7,0,0,7.0,6.0,0.2,30.0*') + def test_AMThermalPrimitive_conversion(): t = AMThermalPrimitive(7, (25.4, 25.4), 25.4, 25.4, 25.4, 0.0) t.to_inch() -- cgit From ef589a064015de3a1ce6487dbb56b99332673e9d Mon Sep 17 00:00:00 2001 From: Paulo Henrique Silva Date: Tue, 26 Nov 2019 00:37:41 -0300 Subject: Migrate to pytest (#111) * Migrate to pytest All tests were update to use pytest. Tests were alse black formatted. Eventually all code will be black formatted but need to merge some PRs first. --- gerber/tests/test_am_statements.py | 412 +++++++++++++++++++------------------ 1 file changed, 210 insertions(+), 202 deletions(-) (limited to 'gerber/tests/test_am_statements.py') diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py index c97556a..0d100b5 100644 --- a/gerber/tests/test_am_statements.py +++ b/gerber/tests/test_am_statements.py @@ -3,385 +3,393 @@ # Author: Hamilton Kibbe -from .tests import * +import pytest + from ..am_statements import * from ..am_statements import inch, metric def test_AMPrimitive_ctor(): - for exposure in ('on', 'off', 'ON', 'OFF'): + for exposure in ("on", "off", "ON", "OFF"): for code in (0, 1, 2, 4, 5, 6, 7, 20, 21, 22): p = AMPrimitive(code, exposure) - assert_equal(p.code, code) - assert_equal(p.exposure, exposure.lower()) + assert p.code == code + assert p.exposure == exposure.lower() def test_AMPrimitive_validation(): - assert_raises(TypeError, AMPrimitive, '1', 'off') - assert_raises(ValueError, AMPrimitive, 0, 'exposed') - assert_raises(ValueError, AMPrimitive, 3, 'off') + pytest.raises(TypeError, AMPrimitive, "1", "off") + pytest.raises(ValueError, AMPrimitive, 0, "exposed") + pytest.raises(ValueError, AMPrimitive, 3, "off") def test_AMPrimitive_conversion(): - p = AMPrimitive(4, 'on') - assert_raises(NotImplementedError, p.to_inch) - assert_raises(NotImplementedError, p.to_metric) + p = AMPrimitive(4, "on") + pytest.raises(NotImplementedError, p.to_inch) + pytest.raises(NotImplementedError, p.to_metric) def test_AMCommentPrimitive_ctor(): - c = AMCommentPrimitive(0, ' This is a comment *') - assert_equal(c.code, 0) - assert_equal(c.comment, 'This is a comment') + c = AMCommentPrimitive(0, " This is a comment *") + assert c.code == 0 + assert c.comment == "This is a comment" def test_AMCommentPrimitive_validation(): - assert_raises(ValueError, AMCommentPrimitive, 1, 'This is a comment') + pytest.raises(ValueError, AMCommentPrimitive, 1, "This is a comment") def test_AMCommentPrimitive_factory(): - c = AMCommentPrimitive.from_gerber('0 Rectangle with rounded corners. *') - assert_equal(c.code, 0) - assert_equal(c.comment, 'Rectangle with rounded corners.') + c = AMCommentPrimitive.from_gerber("0 Rectangle with rounded corners. *") + assert c.code == 0 + assert c.comment == "Rectangle with rounded corners." def test_AMCommentPrimitive_dump(): - c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') - assert_equal(c.to_gerber(), '0 Rectangle with rounded corners. *') + c = AMCommentPrimitive(0, "Rectangle with rounded corners.") + assert c.to_gerber() == "0 Rectangle with rounded corners. *" def test_AMCommentPrimitive_conversion(): - c = AMCommentPrimitive(0, 'Rectangle with rounded corners.') + c = AMCommentPrimitive(0, "Rectangle with rounded corners.") ci = c cm = c ci.to_inch() cm.to_metric() - assert_equal(c, ci) - assert_equal(c, cm) + assert c == ci + assert c == cm def test_AMCommentPrimitive_string(): - c = AMCommentPrimitive(0, 'Test Comment') - assert_equal(str(c), '') + c = AMCommentPrimitive(0, "Test Comment") + assert str(c) == "" def test_AMCirclePrimitive_ctor(): - test_cases = ((1, 'on', 0, (0, 0)), - (1, 'off', 1, (0, 1)), - (1, 'on', 2.5, (0, 2)), - (1, 'off', 5.0, (3, 3))) + test_cases = ( + (1, "on", 0, (0, 0)), + (1, "off", 1, (0, 1)), + (1, "on", 2.5, (0, 2)), + (1, "off", 5.0, (3, 3)), + ) for code, exposure, diameter, position in test_cases: c = AMCirclePrimitive(code, exposure, diameter, position) - assert_equal(c.code, code) - assert_equal(c.exposure, exposure) - assert_equal(c.diameter, diameter) - assert_equal(c.position, position) + assert c.code == code + assert c.exposure == exposure + assert c.diameter == diameter + assert c.position == position def test_AMCirclePrimitive_validation(): - assert_raises(ValueError, AMCirclePrimitive, 2, 'on', 0, (0, 0)) + pytest.raises(ValueError, AMCirclePrimitive, 2, "on", 0, (0, 0)) def test_AMCirclePrimitive_factory(): - c = AMCirclePrimitive.from_gerber('1,0,5,0,0*') - assert_equal(c.code, 1) - assert_equal(c.exposure, 'off') - assert_equal(c.diameter, 5) - assert_equal(c.position, (0, 0)) + c = AMCirclePrimitive.from_gerber("1,0,5,0,0*") + assert c.code == 1 + assert c.exposure == "off" + assert c.diameter == 5 + assert c.position == (0, 0) def test_AMCirclePrimitive_dump(): - c = AMCirclePrimitive(1, 'off', 5, (0, 0)) - assert_equal(c.to_gerber(), '1,0,5,0,0*') - c = AMCirclePrimitive(1, 'on', 5, (0, 0)) - assert_equal(c.to_gerber(), '1,1,5,0,0*') + c = AMCirclePrimitive(1, "off", 5, (0, 0)) + assert c.to_gerber() == "1,0,5,0,0*" + c = AMCirclePrimitive(1, "on", 5, (0, 0)) + assert c.to_gerber() == "1,1,5,0,0*" def test_AMCirclePrimitive_conversion(): - c = AMCirclePrimitive(1, 'off', 25.4, (25.4, 0)) + c = AMCirclePrimitive(1, "off", 25.4, (25.4, 0)) c.to_inch() - assert_equal(c.diameter, 1) - assert_equal(c.position, (1, 0)) + assert c.diameter == 1 + assert c.position == (1, 0) - c = AMCirclePrimitive(1, 'off', 1, (1, 0)) + c = AMCirclePrimitive(1, "off", 1, (1, 0)) c.to_metric() - assert_equal(c.diameter, 25.4) - assert_equal(c.position, (25.4, 0)) + assert c.diameter == 25.4 + assert c.position == (25.4, 0) def test_AMVectorLinePrimitive_validation(): - assert_raises(ValueError, AMVectorLinePrimitive, - 3, 'on', 0.1, (0, 0), (3.3, 5.4), 0) + pytest.raises( + ValueError, AMVectorLinePrimitive, 3, "on", 0.1, (0, 0), (3.3, 5.4), 0 + ) def test_AMVectorLinePrimitive_factory(): - l = AMVectorLinePrimitive.from_gerber('20,1,0.9,0,0.45,12,0.45,0*') - assert_equal(l.code, 20) - assert_equal(l.exposure, 'on') - assert_equal(l.width, 0.9) - assert_equal(l.start, (0, 0.45)) - assert_equal(l.end, (12, 0.45)) - assert_equal(l.rotation, 0) + l = AMVectorLinePrimitive.from_gerber("20,1,0.9,0,0.45,12,0.45,0*") + assert l.code == 20 + assert l.exposure == "on" + assert l.width == 0.9 + assert l.start == (0, 0.45) + assert l.end == (12, 0.45) + assert l.rotation == 0 def test_AMVectorLinePrimitive_dump(): - l = AMVectorLinePrimitive.from_gerber('20,1,0.9,0,0.45,12,0.45,0*') - assert_equal(l.to_gerber(), '20,1,0.9,0.0,0.45,12.0,0.45,0.0*') + l = AMVectorLinePrimitive.from_gerber("20,1,0.9,0,0.45,12,0.45,0*") + assert l.to_gerber() == "20,1,0.9,0.0,0.45,12.0,0.45,0.0*" def test_AMVectorLinePrimtive_conversion(): - l = AMVectorLinePrimitive(20, 'on', 25.4, (0, 0), (25.4, 25.4), 0) + l = AMVectorLinePrimitive(20, "on", 25.4, (0, 0), (25.4, 25.4), 0) l.to_inch() - assert_equal(l.width, 1) - assert_equal(l.start, (0, 0)) - assert_equal(l.end, (1, 1)) + assert l.width == 1 + assert l.start == (0, 0) + assert l.end == (1, 1) - l = AMVectorLinePrimitive(20, 'on', 1, (0, 0), (1, 1), 0) + l = AMVectorLinePrimitive(20, "on", 1, (0, 0), (1, 1), 0) l.to_metric() - assert_equal(l.width, 25.4) - assert_equal(l.start, (0, 0)) - assert_equal(l.end, (25.4, 25.4)) + assert l.width == 25.4 + assert l.start == (0, 0) + assert l.end == (25.4, 25.4) def test_AMOutlinePrimitive_validation(): - assert_raises(ValueError, AMOutlinePrimitive, 7, 'on', - (0, 0), [(3.3, 5.4), (4.0, 5.4), (0, 0)], 0) - assert_raises(ValueError, AMOutlinePrimitive, 4, 'on', - (0, 0), [(3.3, 5.4), (4.0, 5.4), (0, 1)], 0) + pytest.raises( + ValueError, + AMOutlinePrimitive, + 7, + "on", + (0, 0), + [(3.3, 5.4), (4.0, 5.4), (0, 0)], + 0, + ) + pytest.raises( + ValueError, + AMOutlinePrimitive, + 4, + "on", + (0, 0), + [(3.3, 5.4), (4.0, 5.4), (0, 1)], + 0, + ) def test_AMOutlinePrimitive_factory(): - o = AMOutlinePrimitive.from_gerber('4,1,3,0,0,3,3,3,0,0,0,0*') - assert_equal(o.code, 4) - assert_equal(o.exposure, 'on') - assert_equal(o.start_point, (0, 0)) - assert_equal(o.points, [(3, 3), (3, 0), (0, 0)]) - assert_equal(o.rotation, 0) + o = AMOutlinePrimitive.from_gerber("4,1,3,0,0,3,3,3,0,0,0,0*") + assert o.code == 4 + assert o.exposure == "on" + assert o.start_point == (0, 0) + assert o.points == [(3, 3), (3, 0), (0, 0)] + assert o.rotation == 0 def test_AMOUtlinePrimitive_dump(): - o = AMOutlinePrimitive(4, 'on', (0, 0), [(3, 3), (3, 0), (0, 0)], 0) + o = AMOutlinePrimitive(4, "on", (0, 0), [(3, 3), (3, 0), (0, 0)], 0) # New lines don't matter for Gerber, but we insert them to make it easier to remove # For test purposes we can ignore them - assert_equal(o.to_gerber().replace('\n', ''), '4,1,3,0,0,3,3,3,0,0,0,0*') - - + assert o.to_gerber().replace("\n", "") == "4,1,3,0,0,3,3,3,0,0,0,0*" def test_AMOutlinePrimitive_conversion(): - o = AMOutlinePrimitive( - 4, 'on', (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) + o = AMOutlinePrimitive(4, "on", (0, 0), [(25.4, 25.4), (25.4, 0), (0, 0)], 0) o.to_inch() - assert_equal(o.start_point, (0, 0)) - assert_equal(o.points, ((1., 1.), (1., 0.), (0., 0.))) + assert o.start_point == (0, 0) + assert o.points == ((1.0, 1.0), (1.0, 0.0), (0.0, 0.0)) - o = AMOutlinePrimitive(4, 'on', (0, 0), [(1, 1), (1, 0), (0, 0)], 0) + o = AMOutlinePrimitive(4, "on", (0, 0), [(1, 1), (1, 0), (0, 0)], 0) o.to_metric() - assert_equal(o.start_point, (0, 0)) - assert_equal(o.points, ((25.4, 25.4), (25.4, 0), (0, 0))) + assert o.start_point == (0, 0) + assert o.points == ((25.4, 25.4), (25.4, 0), (0, 0)) def test_AMPolygonPrimitive_validation(): - assert_raises(ValueError, AMPolygonPrimitive, 6, 'on', 3, (3.3, 5.4), 3, 0) - assert_raises(ValueError, AMPolygonPrimitive, 5, 'on', 2, (3.3, 5.4), 3, 0) - assert_raises(ValueError, AMPolygonPrimitive, 5, 'on', 13, (3.3, 5.4), 3, 0) + pytest.raises(ValueError, AMPolygonPrimitive, 6, "on", 3, (3.3, 5.4), 3, 0) + pytest.raises(ValueError, AMPolygonPrimitive, 5, "on", 2, (3.3, 5.4), 3, 0) + pytest.raises(ValueError, AMPolygonPrimitive, 5, "on", 13, (3.3, 5.4), 3, 0) def test_AMPolygonPrimitive_factory(): - p = AMPolygonPrimitive.from_gerber('5,1,3,3.3,5.4,3,0') - assert_equal(p.code, 5) - assert_equal(p.exposure, 'on') - assert_equal(p.vertices, 3) - assert_equal(p.position, (3.3, 5.4)) - assert_equal(p.diameter, 3) - assert_equal(p.rotation, 0) + p = AMPolygonPrimitive.from_gerber("5,1,3,3.3,5.4,3,0") + assert p.code == 5 + assert p.exposure == "on" + assert p.vertices == 3 + assert p.position == (3.3, 5.4) + assert p.diameter == 3 + assert p.rotation == 0 def test_AMPolygonPrimitive_dump(): - p = AMPolygonPrimitive(5, 'on', 3, (3.3, 5.4), 3, 0) - assert_equal(p.to_gerber(), '5,1,3,3.3,5.4,3,0*') + p = AMPolygonPrimitive(5, "on", 3, (3.3, 5.4), 3, 0) + assert p.to_gerber() == "5,1,3,3.3,5.4,3,0*" def test_AMPolygonPrimitive_conversion(): - p = AMPolygonPrimitive(5, 'off', 3, (25.4, 0), 25.4, 0) + p = AMPolygonPrimitive(5, "off", 3, (25.4, 0), 25.4, 0) p.to_inch() - assert_equal(p.diameter, 1) - assert_equal(p.position, (1, 0)) + assert p.diameter == 1 + assert p.position == (1, 0) - p = AMPolygonPrimitive(5, 'off', 3, (1, 0), 1, 0) + p = AMPolygonPrimitive(5, "off", 3, (1, 0), 1, 0) p.to_metric() - assert_equal(p.diameter, 25.4) - assert_equal(p.position, (25.4, 0)) + assert p.diameter == 25.4 + assert p.position == (25.4, 0) def test_AMMoirePrimitive_validation(): - assert_raises(ValueError, AMMoirePrimitive, 7, - (0, 0), 5.1, 0.2, 0.4, 6, 0.1, 6.1, 0) + pytest.raises( + ValueError, AMMoirePrimitive, 7, (0, 0), 5.1, 0.2, 0.4, 6, 0.1, 6.1, 0 + ) def test_AMMoirePrimitive_factory(): - m = AMMoirePrimitive.from_gerber('6,0,0,5,0.5,0.5,2,0.1,6,0*') - assert_equal(m.code, 6) - assert_equal(m.position, (0, 0)) - assert_equal(m.diameter, 5) - assert_equal(m.ring_thickness, 0.5) - assert_equal(m.gap, 0.5) - assert_equal(m.max_rings, 2) - assert_equal(m.crosshair_thickness, 0.1) - assert_equal(m.crosshair_length, 6) - assert_equal(m.rotation, 0) + m = AMMoirePrimitive.from_gerber("6,0,0,5,0.5,0.5,2,0.1,6,0*") + assert m.code == 6 + assert m.position == (0, 0) + assert m.diameter == 5 + assert m.ring_thickness == 0.5 + assert m.gap == 0.5 + assert m.max_rings == 2 + assert m.crosshair_thickness == 0.1 + assert m.crosshair_length == 6 + assert m.rotation == 0 def test_AMMoirePrimitive_dump(): - m = AMMoirePrimitive.from_gerber('6,0,0,5,0.5,0.5,2,0.1,6,0*') - assert_equal(m.to_gerber(), '6,0,0,5.0,0.5,0.5,2,0.1,6.0,0.0*') + m = AMMoirePrimitive.from_gerber("6,0,0,5,0.5,0.5,2,0.1,6,0*") + assert m.to_gerber() == "6,0,0,5.0,0.5,0.5,2,0.1,6.0,0.0*" def test_AMMoirePrimitive_conversion(): m = AMMoirePrimitive(6, (25.4, 25.4), 25.4, 25.4, 25.4, 6, 25.4, 25.4, 0) m.to_inch() - assert_equal(m.position, (1., 1.)) - assert_equal(m.diameter, 1.) - assert_equal(m.ring_thickness, 1.) - assert_equal(m.gap, 1.) - assert_equal(m.crosshair_thickness, 1.) - assert_equal(m.crosshair_length, 1.) + assert m.position == (1.0, 1.0) + assert m.diameter == 1.0 + assert m.ring_thickness == 1.0 + assert m.gap == 1.0 + assert m.crosshair_thickness == 1.0 + assert m.crosshair_length == 1.0 m = AMMoirePrimitive(6, (1, 1), 1, 1, 1, 6, 1, 1, 0) m.to_metric() - assert_equal(m.position, (25.4, 25.4)) - assert_equal(m.diameter, 25.4) - assert_equal(m.ring_thickness, 25.4) - assert_equal(m.gap, 25.4) - assert_equal(m.crosshair_thickness, 25.4) - assert_equal(m.crosshair_length, 25.4) + assert m.position == (25.4, 25.4) + assert m.diameter == 25.4 + assert m.ring_thickness == 25.4 + assert m.gap == 25.4 + assert m.crosshair_thickness == 25.4 + assert m.crosshair_length == 25.4 def test_AMThermalPrimitive_validation(): - assert_raises(ValueError, AMThermalPrimitive, 8, (0.0, 0.0), 7, 5, 0.2, 0.0) - assert_raises(TypeError, AMThermalPrimitive, 7, (0.0, '0'), 7, 5, 0.2, 0.0) - - + pytest.raises(ValueError, AMThermalPrimitive, 8, (0.0, 0.0), 7, 5, 0.2, 0.0) + pytest.raises(TypeError, AMThermalPrimitive, 7, (0.0, "0"), 7, 5, 0.2, 0.0) def test_AMThermalPrimitive_factory(): - t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2,45*') - assert_equal(t.code, 7) - assert_equal(t.position, (0, 0)) - assert_equal(t.outer_diameter, 7) - assert_equal(t.inner_diameter, 6) - assert_equal(t.gap, 0.2) - assert_equal(t.rotation, 45) - - + t = AMThermalPrimitive.from_gerber("7,0,0,7,6,0.2,45*") + assert t.code == 7 + assert t.position == (0, 0) + assert t.outer_diameter == 7 + assert t.inner_diameter == 6 + assert t.gap == 0.2 + assert t.rotation == 45 def test_AMThermalPrimitive_dump(): - t = AMThermalPrimitive.from_gerber('7,0,0,7,6,0.2,30*') - assert_equal(t.to_gerber(), '7,0,0,7.0,6.0,0.2,30.0*') - - + t = AMThermalPrimitive.from_gerber("7,0,0,7,6,0.2,30*") + assert t.to_gerber() == "7,0,0,7.0,6.0,0.2,30.0*" def test_AMThermalPrimitive_conversion(): t = AMThermalPrimitive(7, (25.4, 25.4), 25.4, 25.4, 25.4, 0.0) t.to_inch() - assert_equal(t.position, (1., 1.)) - assert_equal(t.outer_diameter, 1.) - assert_equal(t.inner_diameter, 1.) - assert_equal(t.gap, 1.) + assert t.position == (1.0, 1.0) + assert t.outer_diameter == 1.0 + assert t.inner_diameter == 1.0 + assert t.gap == 1.0 t = AMThermalPrimitive(7, (1, 1), 1, 1, 1, 0) t.to_metric() - assert_equal(t.position, (25.4, 25.4)) - assert_equal(t.outer_diameter, 25.4) - assert_equal(t.inner_diameter, 25.4) - assert_equal(t.gap, 25.4) + assert t.position == (25.4, 25.4) + assert t.outer_diameter == 25.4 + assert t.inner_diameter == 25.4 + assert t.gap == 25.4 def test_AMCenterLinePrimitive_validation(): - assert_raises(ValueError, AMCenterLinePrimitive, - 22, 1, 0.2, 0.5, (0, 0), 0) + pytest.raises(ValueError, AMCenterLinePrimitive, 22, 1, 0.2, 0.5, (0, 0), 0) def test_AMCenterLinePrimtive_factory(): - l = AMCenterLinePrimitive.from_gerber('21,1,6.8,1.2,3.4,0.6,0*') - assert_equal(l.code, 21) - assert_equal(l.exposure, 'on') - assert_equal(l.width, 6.8) - assert_equal(l.height, 1.2) - assert_equal(l.center, (3.4, 0.6)) - assert_equal(l.rotation, 0) + l = AMCenterLinePrimitive.from_gerber("21,1,6.8,1.2,3.4,0.6,0*") + assert l.code == 21 + assert l.exposure == "on" + assert l.width == 6.8 + assert l.height == 1.2 + assert l.center == (3.4, 0.6) + assert l.rotation == 0 def test_AMCenterLinePrimitive_dump(): - l = AMCenterLinePrimitive.from_gerber('21,1,6.8,1.2,3.4,0.6,0*') - assert_equal(l.to_gerber(), '21,1,6.8,1.2,3.4,0.6,0.0*') + l = AMCenterLinePrimitive.from_gerber("21,1,6.8,1.2,3.4,0.6,0*") + assert l.to_gerber() == "21,1,6.8,1.2,3.4,0.6,0.0*" def test_AMCenterLinePrimitive_conversion(): - l = AMCenterLinePrimitive(21, 'on', 25.4, 25.4, (25.4, 25.4), 0) + l = AMCenterLinePrimitive(21, "on", 25.4, 25.4, (25.4, 25.4), 0) l.to_inch() - assert_equal(l.width, 1.) - assert_equal(l.height, 1.) - assert_equal(l.center, (1., 1.)) + assert l.width == 1.0 + assert l.height == 1.0 + assert l.center == (1.0, 1.0) - l = AMCenterLinePrimitive(21, 'on', 1, 1, (1, 1), 0) + l = AMCenterLinePrimitive(21, "on", 1, 1, (1, 1), 0) l.to_metric() - assert_equal(l.width, 25.4) - assert_equal(l.height, 25.4) - assert_equal(l.center, (25.4, 25.4)) + assert l.width == 25.4 + assert l.height == 25.4 + assert l.center == (25.4, 25.4) def test_AMLowerLeftLinePrimitive_validation(): - assert_raises(ValueError, AMLowerLeftLinePrimitive, - 23, 1, 0.2, 0.5, (0, 0), 0) + pytest.raises(ValueError, AMLowerLeftLinePrimitive, 23, 1, 0.2, 0.5, (0, 0), 0) def test_AMLowerLeftLinePrimtive_factory(): - l = AMLowerLeftLinePrimitive.from_gerber('22,1,6.8,1.2,3.4,0.6,0*') - assert_equal(l.code, 22) - assert_equal(l.exposure, 'on') - assert_equal(l.width, 6.8) - assert_equal(l.height, 1.2) - assert_equal(l.lower_left, (3.4, 0.6)) - assert_equal(l.rotation, 0) + l = AMLowerLeftLinePrimitive.from_gerber("22,1,6.8,1.2,3.4,0.6,0*") + assert l.code == 22 + assert l.exposure == "on" + assert l.width == 6.8 + assert l.height == 1.2 + assert l.lower_left == (3.4, 0.6) + assert l.rotation == 0 def test_AMLowerLeftLinePrimitive_dump(): - l = AMLowerLeftLinePrimitive.from_gerber('22,1,6.8,1.2,3.4,0.6,0*') - assert_equal(l.to_gerber(), '22,1,6.8,1.2,3.4,0.6,0.0*') + l = AMLowerLeftLinePrimitive.from_gerber("22,1,6.8,1.2,3.4,0.6,0*") + assert l.to_gerber() == "22,1,6.8,1.2,3.4,0.6,0.0*" def test_AMLowerLeftLinePrimitive_conversion(): - l = AMLowerLeftLinePrimitive(22, 'on', 25.4, 25.4, (25.4, 25.4), 0) + l = AMLowerLeftLinePrimitive(22, "on", 25.4, 25.4, (25.4, 25.4), 0) l.to_inch() - assert_equal(l.width, 1.) - assert_equal(l.height, 1.) - assert_equal(l.lower_left, (1., 1.)) + assert l.width == 1.0 + assert l.height == 1.0 + assert l.lower_left == (1.0, 1.0) - l = AMLowerLeftLinePrimitive(22, 'on', 1, 1, (1, 1), 0) + l = AMLowerLeftLinePrimitive(22, "on", 1, 1, (1, 1), 0) l.to_metric() - assert_equal(l.width, 25.4) - assert_equal(l.height, 25.4) - assert_equal(l.lower_left, (25.4, 25.4)) + assert l.width == 25.4 + assert l.height == 25.4 + assert l.lower_left == (25.4, 25.4) def test_AMUnsupportPrimitive(): - u = AMUnsupportPrimitive.from_gerber('Test') - assert_equal(u.primitive, 'Test') - u = AMUnsupportPrimitive('Test') - assert_equal(u.to_gerber(), 'Test') + u = AMUnsupportPrimitive.from_gerber("Test") + assert u.primitive == "Test" + u = AMUnsupportPrimitive("Test") + assert u.to_gerber() == "Test" def test_AMUnsupportPrimitive_smoketest(): - u = AMUnsupportPrimitive.from_gerber('Test') + u = AMUnsupportPrimitive.from_gerber("Test") u.to_inch() u.to_metric() def test_inch(): - assert_equal(inch(25.4), 1) + assert inch(25.4) == 1 def test_metric(): - assert_equal(metric(1), 25.4) + assert metric(1) == 25.4 -- cgit