From 18e3b87625ddb739faeddffcaed48e12db6c7e8b Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Sun, 19 Oct 2014 22:23:00 -0400 Subject: Test update --- gerber/tests/test_common.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gerber/tests/test_common.py (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py new file mode 100644 index 0000000..1e1efe5 --- /dev/null +++ b/gerber/tests/test_common.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +# Author: Hamilton Kibbe +from ..common import read +from ..excellon import ExcellonFile +from ..rs274x import GerberFile +from tests import * + +import os + + +NCDRILL_FILE = os.path.join(os.path.dirname(__file__), + 'resources/ncdrill.DRD') +TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), + 'resources/top_copper.GTL') + +def test_file_type_detection(): + """ Test file type detection + """ + ncdrill = read(NCDRILL_FILE) + top_copper = read(TOP_COPPER_FILE) + assert(isinstance(ncdrill, ExcellonFile)) + assert(isinstance(top_copper, GerberFile)) -- cgit From d98d23f8b5d61bb9d20e743a3c44bf04b6b2330a Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Mon, 2 Feb 2015 00:43:08 -0500 Subject: More tests and bugfixes --- gerber/tests/test_common.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py index 1e1efe5..bf9760a 100644 --- a/gerber/tests/test_common.py +++ b/gerber/tests/test_common.py @@ -20,5 +20,12 @@ def test_file_type_detection(): """ ncdrill = read(NCDRILL_FILE) top_copper = read(TOP_COPPER_FILE) - assert(isinstance(ncdrill, ExcellonFile)) - assert(isinstance(top_copper, GerberFile)) + assert_true(isinstance(ncdrill, ExcellonFile)) + assert_true(isinstance(top_copper, GerberFile)) + +def test_file_type_validation(): + """ Test file format validation + """ + assert_raises(TypeError, read, 'LICENSE') + + -- 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_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py index bf9760a..76e3991 100644 --- a/gerber/tests/test_common.py +++ b/gerber/tests/test_common.py @@ -5,7 +5,7 @@ from ..common import read from ..excellon import ExcellonFile from ..rs274x import GerberFile -from tests import * +from .tests import * import os -- 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_common.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py index 76e3991..0ba4b68 100644 --- a/gerber/tests/test_common.py +++ b/gerber/tests/test_common.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Author: Hamilton Kibbe -from ..common import read +from ..common import read, loads from ..excellon import ExcellonFile from ..rs274x import GerberFile from .tests import * @@ -23,9 +23,20 @@ def test_file_type_detection(): assert_true(isinstance(ncdrill, ExcellonFile)) assert_true(isinstance(top_copper, GerberFile)) + +def test_load_from_string(): + with open(NCDRILL_FILE, 'r') as f: + ncdrill = loads(f.read()) + with open(TOP_COPPER_FILE, 'r') as f: + top_copper = loads(f.read()) + assert_true(isinstance(ncdrill, ExcellonFile)) + assert_true(isinstance(top_copper, GerberFile)) + + def test_file_type_validation(): """ Test file format validation """ assert_raises(TypeError, read, 'LICENSE') + -- 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_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py index 0ba4b68..7c66c0f 100644 --- a/gerber/tests/test_common.py +++ b/gerber/tests/test_common.py @@ -25,9 +25,9 @@ def test_file_type_detection(): def test_load_from_string(): - with open(NCDRILL_FILE, 'r') as f: + with open(NCDRILL_FILE, 'rU') as f: ncdrill = loads(f.read()) - with open(TOP_COPPER_FILE, 'r') as f: + with open(TOP_COPPER_FILE, 'rU') as f: top_copper = loads(f.read()) assert_true(isinstance(ncdrill, ExcellonFile)) assert_true(isinstance(top_copper, GerberFile)) -- 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_common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py index 7c66c0f..5991e5e 100644 --- a/gerber/tests/test_common.py +++ b/gerber/tests/test_common.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Author: Hamilton Kibbe +from ..exceptions import ParseError from ..common import read, loads from ..excellon import ExcellonFile from ..rs274x import GerberFile @@ -31,12 +32,12 @@ def test_load_from_string(): top_copper = loads(f.read()) assert_true(isinstance(ncdrill, ExcellonFile)) assert_true(isinstance(top_copper, GerberFile)) - + def test_file_type_validation(): """ Test file format validation """ - assert_raises(TypeError, read, 'LICENSE') + assert_raises(ParseError, read, 'LICENSE') -- 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_common.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py index 5991e5e..357ed18 100644 --- a/gerber/tests/test_common.py +++ b/gerber/tests/test_common.py @@ -12,9 +12,10 @@ import os NCDRILL_FILE = os.path.join(os.path.dirname(__file__), - 'resources/ncdrill.DRD') + 'resources/ncdrill.DRD') TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), - 'resources/top_copper.GTL') + 'resources/top_copper.GTL') + def test_file_type_detection(): """ Test file type detection @@ -38,6 +39,3 @@ def test_file_type_validation(): """ Test file format validation """ assert_raises(ParseError, read, 'LICENSE') - - - -- cgit From 724c2b3bced319ed0b50c4302fed9b0e1aa9ce9c Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Sat, 5 Nov 2016 20:56:47 -0400 Subject: Finish Merge, most tests passing --- gerber/tests/test_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py index 357ed18..0224c48 100644 --- a/gerber/tests/test_common.py +++ b/gerber/tests/test_common.py @@ -38,4 +38,4 @@ def test_load_from_string(): def test_file_type_validation(): """ Test file format validation """ - assert_raises(ParseError, read, 'LICENSE') + assert_raises(ParseError, read, __file__) -- 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_common.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'gerber/tests/test_common.py') diff --git a/gerber/tests/test_common.py b/gerber/tests/test_common.py index 0224c48..a6b1264 100644 --- a/gerber/tests/test_common.py +++ b/gerber/tests/test_common.py @@ -6,15 +6,12 @@ from ..exceptions import ParseError from ..common import read, loads from ..excellon import ExcellonFile from ..rs274x import GerberFile -from .tests import * - import os +import pytest -NCDRILL_FILE = os.path.join(os.path.dirname(__file__), - 'resources/ncdrill.DRD') -TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), - 'resources/top_copper.GTL') +NCDRILL_FILE = os.path.join(os.path.dirname(__file__), "resources/ncdrill.DRD") +TOP_COPPER_FILE = os.path.join(os.path.dirname(__file__), "resources/top_copper.GTL") def test_file_type_detection(): @@ -22,20 +19,20 @@ def test_file_type_detection(): """ ncdrill = read(NCDRILL_FILE) top_copper = read(TOP_COPPER_FILE) - assert_true(isinstance(ncdrill, ExcellonFile)) - assert_true(isinstance(top_copper, GerberFile)) + assert isinstance(ncdrill, ExcellonFile) + assert isinstance(top_copper, GerberFile) def test_load_from_string(): - with open(NCDRILL_FILE, 'rU') as f: + with open(NCDRILL_FILE, "rU") as f: ncdrill = loads(f.read()) - with open(TOP_COPPER_FILE, 'rU') as f: + with open(TOP_COPPER_FILE, "rU") as f: top_copper = loads(f.read()) - assert_true(isinstance(ncdrill, ExcellonFile)) - assert_true(isinstance(top_copper, GerberFile)) + assert isinstance(ncdrill, ExcellonFile) + assert isinstance(top_copper, GerberFile) def test_file_type_validation(): """ Test file format validation """ - assert_raises(ParseError, read, __file__) + pytest.raises(ParseError, read, __file__) -- cgit