From c054136a6531404e3b20aadbc7fba2ec25b50a4a Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Mon, 26 Jan 2015 22:16:00 -0500 Subject: Added some tests --- gerber/tests/test_rs274x.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gerber/tests/test_rs274x.py') diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index f66a09e..5d528dc 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -14,3 +14,14 @@ TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), def test_read(): top_copper = read(TOP_COPPER_FILE) assert(isinstance(top_copper, GerberFile)) + +def test_comments_parameter(): + top_copper = read(TOP_COPPER_FILE) + assert_equal(top_copper.comments[0], 'This is a comment,:') + +def test_size_parameter(): + top_copper = read(TOP_COPPER_FILE) + size = top_copper.size + assert_equal(size[0], 2.2869) + assert_equal(size[1], 1.8064) + -- 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_rs274x.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'gerber/tests/test_rs274x.py') diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index 5d528dc..27f6f49 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -2,10 +2,11 @@ # -*- coding: utf-8 -*- # Author: Hamilton Kibbe +import os + from ..rs274x import read, GerberFile from tests import * -import os TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), 'resources/top_copper.GTL') @@ -25,3 +26,20 @@ def test_size_parameter(): assert_equal(size[0], 2.2869) assert_equal(size[1], 1.8064) +def test_conversion(): + import copy + top_copper = read(TOP_COPPER_FILE) + assert_equal(top_copper.units, 'inch') + top_copper_inch = copy.deepcopy(top_copper) + top_copper.to_metric() + for statement in top_copper_inch.statements: + statement.to_metric() + for primitive in top_copper_inch.primitives: + primitive.to_metric() + assert_equal(top_copper.units, 'metric') + for i, m in zip(top_copper.statements, top_copper_inch.statements): + assert_equal(i, m) + + for i, m in zip(top_copper.primitives, top_copper_inch.primitives): + assert_equal(i, m) + -- cgit From 7ace94b0230e9acd85097c1812840250d551015c Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Wed, 18 Feb 2015 15:35:01 +0100 Subject: Make gerber.render a package & fix more relative import statements --- gerber/tests/test_rs274x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gerber/tests/test_rs274x.py') diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index 27f6f49..5185fa1 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -5,7 +5,7 @@ import os from ..rs274x import read, GerberFile -from tests import * +from .tests import * TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), -- cgit From 2ea9b8ad97df43f3aa483421596162e88fa7980e Mon Sep 17 00:00:00 2001 From: Paulo Henrique Silva Date: Fri, 20 Feb 2015 14:06:45 -0200 Subject: Fix size test, board is slight out of origin, so size does change now that we properly handle non-zero origins --- gerber/tests/test_rs274x.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gerber/tests/test_rs274x.py') diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index 5185fa1..3d560de 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -23,8 +23,8 @@ def test_comments_parameter(): def test_size_parameter(): top_copper = read(TOP_COPPER_FILE) size = top_copper.size - assert_equal(size[0], 2.2869) - assert_equal(size[1], 1.8064) + assert_equal(size[0], 2.2569) + assert_equal(size[1], 1.5000) def test_conversion(): import copy -- cgit From dbe93f77e5d9630c035f204a932284372ecf124d Mon Sep 17 00:00:00 2001 From: Paulo Henrique Silva Date: Fri, 20 Feb 2015 14:19:43 -0200 Subject: Fix floating point equality test --- gerber/tests/test_rs274x.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gerber/tests/test_rs274x.py') diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index 3d560de..a3d20ed 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -23,8 +23,8 @@ def test_comments_parameter(): def test_size_parameter(): top_copper = read(TOP_COPPER_FILE) size = top_copper.size - assert_equal(size[0], 2.2569) - assert_equal(size[1], 1.5000) + assert_almost_equal(size[0], 2.256900, 6) + assert_almost_equal(size[1], 1.500000, 6) def test_conversion(): import copy -- cgit From aff36a4dca0d2d06b00c5f1e1a0703400fbe3b6b Mon Sep 17 00:00:00 2001 From: Paulo Henrique Silva Date: Thu, 21 May 2015 16:15:55 -0300 Subject: Fix multiline read of mixed statements (%XXX*% followed by DNN*) We now check if there is a %XXX*% command inside the line before considering it a multiline statement. --- gerber/tests/test_rs274x.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gerber/tests/test_rs274x.py') diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index a3d20ed..c084e80 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -11,11 +11,19 @@ from .tests import * TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), 'resources/top_copper.GTL') +MULTILINE_READ_FILE = os.path.join(os.path.dirname(__file__), + 'resources/multiline_read.ger') + def test_read(): top_copper = read(TOP_COPPER_FILE) assert(isinstance(top_copper, GerberFile)) +def test_multiline_read(): + multiline = read(MULTILINE_READ_FILE) + assert(isinstance(multiline, GerberFile)) + assert_equal(10, len(multiline.statements)) + def test_comments_parameter(): top_copper = read(TOP_COPPER_FILE) assert_equal(top_copper.comments[0], 'This is a comment,:') -- 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_rs274x.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gerber/tests/test_rs274x.py') diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index c084e80..d5acfe8 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -9,31 +9,35 @@ from .tests import * TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), - 'resources/top_copper.GTL') + 'resources/top_copper.GTL') MULTILINE_READ_FILE = os.path.join(os.path.dirname(__file__), - 'resources/multiline_read.ger') + 'resources/multiline_read.ger') def test_read(): top_copper = read(TOP_COPPER_FILE) assert(isinstance(top_copper, GerberFile)) + def test_multiline_read(): multiline = read(MULTILINE_READ_FILE) assert(isinstance(multiline, GerberFile)) assert_equal(10, len(multiline.statements)) + def test_comments_parameter(): top_copper = read(TOP_COPPER_FILE) assert_equal(top_copper.comments[0], 'This is a comment,:') + def test_size_parameter(): top_copper = read(TOP_COPPER_FILE) size = top_copper.size assert_almost_equal(size[0], 2.256900, 6) assert_almost_equal(size[1], 1.500000, 6) + def test_conversion(): import copy top_copper = read(TOP_COPPER_FILE) @@ -50,4 +54,3 @@ def test_conversion(): for i, m in zip(top_copper.primitives, top_copper_inch.primitives): assert_equal(i, m) - -- cgit