diff options
author | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-10-10 16:51:21 -0400 |
---|---|---|
committer | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-10-10 16:51:21 -0400 |
commit | dd63b169f177389602e17bc6ced53bd0f1ba0de3 (patch) | |
tree | 12be6d968c97be78c3910b2c84b048211e88c7e2 /gerber/tests/test_common.py | |
parent | b81c9d4bf96845ced3495eb158ec3a3c9e4dce3d (diff) | |
download | gerbonara-dd63b169f177389602e17bc6ced53bd0f1ba0de3.tar.gz gerbonara-dd63b169f177389602e17bc6ced53bd0f1ba0de3.tar.bz2 gerbonara-dd63b169f177389602e17bc6ced53bd0f1ba0de3.zip |
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
Diffstat (limited to 'gerber/tests/test_common.py')
-rw-r--r-- | gerber/tests/test_common.py | 13 |
1 files changed, 12 insertions, 1 deletions
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 <ham@hamiltonkib.be> -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') + |