Port old pcb-tools-extension unit tests to pytest
This commit is contained in:
parent
7bebf9fe62
commit
d0f836ecfa
40 changed files with 263 additions and 310 deletions
|
|
@ -4,10 +4,10 @@
|
|||
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
|
||||
|
||||
import unittest
|
||||
from gerbonara.gerber.panelize.am_expression import *
|
||||
from gerbonara.gerber.panelize.am_expression import AMOperatorExpression as Op
|
||||
from gerbonara.gerber.utils import inch, metric
|
||||
from gerbonara.gerber.am_read import read_macro
|
||||
from ...panelize.am_expression import *
|
||||
from ...panelize.am_expression import AMOperatorExpression as Op
|
||||
from ...utils import inch, metric
|
||||
from ...am_read import read_macro
|
||||
|
||||
class TestAMConstantExpression(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -204,5 +204,3 @@ class TestEvalMacro(unittest.TestCase):
|
|||
gerber += '${0}={1}*'.format(-number, expressions[0].to_gerber())
|
||||
return gerber
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
132
gerbonara/gerber/tests/panelize/test_dxf.py
Normal file
132
gerbonara/gerber/tests/panelize/test_dxf.py
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from contextlib import contextmanager
|
||||
import unittest
|
||||
from ... import panelize
|
||||
from ...utils import inch, metric
|
||||
|
||||
|
||||
class TestExcellon(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
here = Path(__file__).parent
|
||||
cls.EXPECTSDIR = here / 'expects'
|
||||
|
||||
cls.METRIC_FILE = here / 'data' / 'ref_dxf_metric.dxf'
|
||||
cls.INCH_FILE = here / 'data' / 'ref_dxf_inch.dxf'
|
||||
cls.COMPLEX_FILE = here / 'data' / 'ref_dxf_complex.dxf'
|
||||
|
||||
@contextmanager
|
||||
def _check_result(self, reference_fn):
|
||||
with tempfile.NamedTemporaryFile('rb') as tmp_out:
|
||||
yield tmp_out.name
|
||||
|
||||
actual = tmp_out.read()
|
||||
expected = (self.EXPECTSDIR / reference_fn).read_bytes()
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_save_line(self):
|
||||
with self._check_result('dxf_save_line.gtl') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_LINE
|
||||
dxf.width = 0.2
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_save_fill(self):
|
||||
with self._check_result('dxf_save_fill.gtl') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_FILL
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_save_fill_simple(self):
|
||||
with self._check_result('dxf_save_fill_simple.gtl') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_FILL
|
||||
dxf.fill_mode = dxf.FM_SIMPLE
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_save_mousebites(self):
|
||||
with self._check_result('dxf_save_mousebites.gtl') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_MOUSE_BITES
|
||||
dxf.width = 0.5
|
||||
dxf.pitch = 1.4
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_save_excellon(self):
|
||||
with self._check_result('dxf_save_line.txt') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_LINE
|
||||
dxf.format = (3,3)
|
||||
dxf.width = 0.2
|
||||
dxf.write(outfile, filetype=dxf.FT_EXCELLON)
|
||||
|
||||
def test_save_excellon_mousebites(self):
|
||||
with self._check_result('dxf_save_mousebites.txt') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_MOUSE_BITES
|
||||
dxf.format = (3, 3)
|
||||
dxf.width = 0.5
|
||||
dxf.pitch = 1.4
|
||||
dxf.write(outfile, filetype=dxf.FT_EXCELLON)
|
||||
|
||||
def test_to_inch(self):
|
||||
with self._check_result('dxf_to_inch.gtl') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.to_inch()
|
||||
dxf.format = (2, 5)
|
||||
dxf.write(outfile)
|
||||
|
||||
def _test_to_metric(self):
|
||||
with self._check_result('dxf_to_metric.gtl') as outfile:
|
||||
dxf = panelize.read(self.INCH_FILE)
|
||||
dxf.to_metric()
|
||||
dxf.format = (3, 5)
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_offset(self):
|
||||
with self._check_result('dxf_offset.gtl') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.offset(11, 5)
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_rotate(self):
|
||||
with self._check_result('dxf_rotate.gtl') as outfile:
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.rotate(20, (10, 10))
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_rectangle_metric(self):
|
||||
with self._check_result('dxf_rectangle_metric.gtl') as outfile:
|
||||
dxf = panelize.DxfFile.rectangle(width=10, height=10, units='metric')
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_rectangle_inch(self):
|
||||
with self._check_result('dxf_rectangle_inch.gtl') as outfile:
|
||||
dxf = panelize.DxfFile.rectangle(width=inch(10), height=inch(10), units='inch')
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_complex_fill(self):
|
||||
with self._check_result('dxf_complex_fill.gtl') as outfile:
|
||||
dxf = panelize.read(self.COMPLEX_FILE)
|
||||
dxf.draw_mode = dxf.DM_FILL
|
||||
dxf.write(outfile)
|
||||
|
||||
def test_complex_fill_flip(self):
|
||||
with self._check_result('dxf_complex_fill_flip.gtl') as outfile:
|
||||
ctx = panelize.GerberComposition()
|
||||
base = panelize.rectangle(width=100, height=100, left=0, bottom=0, units='metric')
|
||||
base.draw_mode = base.DM_FILL
|
||||
ctx.merge(base)
|
||||
dxf = panelize.read(self.COMPLEX_FILE)
|
||||
dxf.negate_polarity()
|
||||
dxf.draw_mode = dxf.DM_FILL
|
||||
ctx.merge(dxf)
|
||||
ctx.dump(outfile)
|
||||
|
||||
60
gerbonara/gerber/tests/panelize/test_excellon.py
Normal file
60
gerbonara/gerber/tests/panelize/test_excellon.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from contextlib import contextmanager
|
||||
import unittest
|
||||
from ... import panelize
|
||||
|
||||
class TestExcellon(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
here = Path(__file__).parent
|
||||
cls.EXPECTSDIR = here / 'expects'
|
||||
cls.METRIC_FILE = here / 'data' / 'ref_drill_metric.txt'
|
||||
cls.INCH_FILE = here / 'data' / 'ref_drill_inch.txt'
|
||||
|
||||
@contextmanager
|
||||
def _check_result(self, reference_fn):
|
||||
with tempfile.NamedTemporaryFile('rb') as tmp_out:
|
||||
yield tmp_out.name
|
||||
|
||||
actual = tmp_out.read()
|
||||
expected = (self.EXPECTSDIR / reference_fn).read_bytes()
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_save(self):
|
||||
with self._check_result('excellon_save.txt') as outfile:
|
||||
drill = panelize.read(self.METRIC_FILE)
|
||||
drill.write(outfile)
|
||||
|
||||
def test_to_inch(self):
|
||||
with self._check_result('excellon_to_inch.txt') as outfile:
|
||||
drill = panelize.read(self.METRIC_FILE)
|
||||
drill.to_inch()
|
||||
drill.format = (2, 4)
|
||||
drill.write(outfile)
|
||||
|
||||
def test_to_metric(self):
|
||||
with self._check_result('excellon_to_metric.txt') as outfile:
|
||||
drill = panelize.read(self.INCH_FILE)
|
||||
drill.to_metric()
|
||||
drill.format = (3, 3)
|
||||
drill.write(outfile)
|
||||
|
||||
def test_offset(self):
|
||||
with self._check_result('excellon_offset.txt') as outfile:
|
||||
drill = panelize.read(self.METRIC_FILE)
|
||||
drill.offset(11, 5)
|
||||
drill.write(outfile)
|
||||
|
||||
def test_rotate(self):
|
||||
with self._check_result('excellon_rotate.txt') as outfile:
|
||||
drill = panelize.read(self.METRIC_FILE)
|
||||
drill.rotate(20, (10, 10))
|
||||
drill.write(outfile)
|
||||
|
||||
66
gerbonara/gerber/tests/panelize/test_rs274x.py
Normal file
66
gerbonara/gerber/tests/panelize/test_rs274x.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from contextlib import contextmanager
|
||||
import unittest
|
||||
from ... import panelize
|
||||
|
||||
class TestRs274x(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
here = Path(__file__).parent
|
||||
cls.EXPECTSDIR = here / 'expects'
|
||||
cls.METRIC_FILE = here / 'data' / 'ref_gerber_metric.gtl'
|
||||
cls.INCH_FILE = here / 'data' / 'ref_gerber_inch.gtl'
|
||||
cls.SQ_FILE = here / 'data' / 'ref_gerber_single_quadrant.gtl'
|
||||
|
||||
@contextmanager
|
||||
def _check_result(self, reference_fn):
|
||||
with tempfile.NamedTemporaryFile('rb') as tmp_out:
|
||||
yield tmp_out.name
|
||||
|
||||
actual = tmp_out.read()
|
||||
expected = (self.EXPECTSDIR / reference_fn).read_bytes()
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_save(self):
|
||||
with self._check_result('RS2724x_save.gtl') as outfile:
|
||||
gerber = panelize.read(self.METRIC_FILE)
|
||||
gerber.write(outfile)
|
||||
|
||||
def test_to_inch(self):
|
||||
with self._check_result('RS2724x_to_inch.gtl') as outfile:
|
||||
gerber = panelize.read(self.METRIC_FILE)
|
||||
gerber.to_inch()
|
||||
gerber.format = (2,5)
|
||||
gerber.write(outfile)
|
||||
|
||||
def test_to_metric(self):
|
||||
with self._check_result('RS2724x_to_metric.gtl') as outfile:
|
||||
gerber = panelize.read(self.INCH_FILE)
|
||||
gerber.to_metric()
|
||||
gerber.format = (3, 4)
|
||||
gerber.write(outfile)
|
||||
|
||||
def test_offset(self):
|
||||
with self._check_result('RS2724x_offset.gtl') as outfile:
|
||||
gerber = panelize.read(self.METRIC_FILE)
|
||||
gerber.offset(11, 5)
|
||||
gerber.write(outfile)
|
||||
|
||||
def test_rotate(self):
|
||||
with self._check_result('RS2724x_rotate.gtl') as outfile:
|
||||
gerber = panelize.read(self.METRIC_FILE)
|
||||
gerber.rotate(20, (10,10))
|
||||
gerber.write(outfile)
|
||||
|
||||
def test_single_quadrant(self):
|
||||
with self._check_result('RS2724x_single_quadrant.gtl') as outfile:
|
||||
gerber = panelize.read(self.SQ_FILE)
|
||||
gerber.write(outfile)
|
||||
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import unittest
|
||||
|
||||
from gerbonara.gerber.panelize.utility import *
|
||||
from ...panelize.utility import *
|
||||
from math import sqrt
|
||||
|
||||
class TestUtility(unittest.TestCase):
|
||||
|
|
@ -61,5 +61,3 @@ class TestUtility(unittest.TestCase):
|
|||
self.assertFalse(is_equal_point(p1, p0, 0.001))
|
||||
self.assertFalse(is_equal_point(p1, p0))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from gerbonara.gerber import panelize
|
||||
from gerbonara.gerber.utils import inch, metric
|
||||
|
||||
|
||||
class TestExcellon(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
cls.INDIR = 'data'
|
||||
cls.OUTDIR = 'outputs'
|
||||
cls.EXPECTSDIR = 'expects'
|
||||
cls.OUTPREFIX = 'dxf_'
|
||||
cls.METRIC_FILE = os.path.join(cls.INDIR, 'ref_dxf_metric.dxf')
|
||||
cls.INCH_FILE = os.path.join(cls.INDIR, 'ref_dxf_inch.dxf')
|
||||
cls.COMPLEX_FILE = os.path.join(cls.INDIR, 'ref_dxf_complex.dxf')
|
||||
try:
|
||||
os.mkdir(cls.OUTDIR)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
def _checkResult(self, file):
|
||||
with open(file, 'r') as f:
|
||||
data = f.read()
|
||||
with open(os.path.join(self.EXPECTSDIR, os.path.basename(file)), 'r') as f:
|
||||
expect = f.read()
|
||||
self.assertEqual(data, expect)
|
||||
|
||||
def test_save_line(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'save_line.gtl')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_LINE
|
||||
dxf.width = 0.2
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_save_fill(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'save_fill.gtl')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_FILL
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_save_fill_simple(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'save_fill_simple.gtl')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_FILL
|
||||
dxf.fill_mode = dxf.FM_SIMPLE
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_save_mousebites(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'save_mousebites.gtl')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_MOUSE_BITES
|
||||
dxf.width = 0.5
|
||||
dxf.pitch = 1.4
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_save_excellon(self):
|
||||
outfile = os.path.join(
|
||||
self.OUTDIR, self.OUTPREFIX + 'save_line.txt')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_LINE
|
||||
dxf.format = (3,3)
|
||||
dxf.width = 0.2
|
||||
dxf.write(outfile, filetype=dxf.FT_EXCELLON)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_save_excellon_mousebites(self):
|
||||
outfile = os.path.join(
|
||||
self.OUTDIR, self.OUTPREFIX + 'save_mousebites.txt')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.draw_mode = dxf.DM_MOUSE_BITES
|
||||
dxf.format = (3, 3)
|
||||
dxf.width = 0.5
|
||||
dxf.pitch = 1.4
|
||||
dxf.write(outfile, filetype=dxf.FT_EXCELLON)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_to_inch(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'to_inch.gtl')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.to_inch()
|
||||
dxf.format = (2, 5)
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def _test_to_metric(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'to_metric.gtl')
|
||||
dxf = panelize.read(self.INCH_FILE)
|
||||
dxf.to_metric()
|
||||
dxf.format = (3, 5)
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_offset(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'offset.gtl')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.offset(11, 5)
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_rotate(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'rotate.gtl')
|
||||
dxf = panelize.read(self.METRIC_FILE)
|
||||
dxf.rotate(20, (10, 10))
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_rectangle_metric(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'rectangle_metric.gtl')
|
||||
dxf = panelize.DxfFile.rectangle(width=10, height=10, units='metric')
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_rectangle_inch(self):
|
||||
outfile = os.path.join(
|
||||
self.OUTDIR, self.OUTPREFIX + 'rectangle_inch.gtl')
|
||||
dxf = panelize.DxfFile.rectangle(width=inch(10), height=inch(10), units='inch')
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_complex_fill(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'complex_fill.gtl')
|
||||
dxf = panelize.read(self.COMPLEX_FILE)
|
||||
dxf.draw_mode = dxf.DM_FILL
|
||||
dxf.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_complex_fill_flip(self):
|
||||
outfile = os.path.join(
|
||||
self.OUTDIR, self.OUTPREFIX + 'complex_fill_flip.gtl')
|
||||
ctx = panelize.GerberComposition()
|
||||
base = panelize.rectangle(width=100, height=100, left=0, bottom=0, units='metric')
|
||||
base.draw_mode = base.DM_FILL
|
||||
ctx.merge(base)
|
||||
dxf = panelize.read(self.COMPLEX_FILE)
|
||||
dxf.negate_polarity()
|
||||
dxf.draw_mode = dxf.DM_FILL
|
||||
ctx.merge(dxf)
|
||||
ctx.dump(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from gerbonara.gerber import panelize
|
||||
|
||||
|
||||
class TestExcellon(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
cls.INDIR = 'data'
|
||||
cls.OUTDIR = 'outputs'
|
||||
cls.EXPECTSDIR = 'expects'
|
||||
cls.OUTPREFIX = 'excellon_'
|
||||
cls.METRIC_FILE = os.path.join(cls.INDIR, 'ref_drill_metric.txt')
|
||||
cls.INCH_FILE = os.path.join(cls.INDIR, 'ref_drill_inch.txt')
|
||||
try:
|
||||
os.mkdir(cls.OUTDIR)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
def _checkResult(self, file):
|
||||
with open(file, 'r') as f:
|
||||
data = f.read()
|
||||
with open(os.path.join(self.EXPECTSDIR, os.path.basename(file)), 'r') as f:
|
||||
expect = f.read()
|
||||
self.assertEqual(data, expect)
|
||||
pass
|
||||
|
||||
def test_save(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'save.txt')
|
||||
drill = panelize.read(self.METRIC_FILE)
|
||||
drill.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_to_inch(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'to_inch.txt')
|
||||
drill = panelize.read(self.METRIC_FILE)
|
||||
drill.to_inch()
|
||||
drill.format = (2, 4)
|
||||
drill.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_to_metric(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'to_metric.txt')
|
||||
drill = panelize.read(self.INCH_FILE)
|
||||
drill.to_metric()
|
||||
drill.format = (3, 3)
|
||||
drill.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_offset(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'offset.txt')
|
||||
drill = panelize.read(self.METRIC_FILE)
|
||||
drill.offset(11, 5)
|
||||
drill.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_rotate(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'rotate.txt')
|
||||
drill = panelize.read(self.METRIC_FILE)
|
||||
drill.rotate(20, (10, 10))
|
||||
drill.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from gerbonara.gerber import panelize
|
||||
|
||||
class TestRs274x(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
cls.INDIR = 'data'
|
||||
cls.OUTDIR = 'outputs'
|
||||
cls.EXPECTSDIR = 'expects'
|
||||
cls.OUTPREFIX = 'RS2724x_'
|
||||
cls.METRIC_FILE = os.path.join(cls.INDIR, 'ref_gerber_metric.gtl')
|
||||
cls.INCH_FILE = os.path.join(cls.INDIR, 'ref_gerber_inch.gtl')
|
||||
cls.SQ_FILE = os.path.join(cls.INDIR, 'ref_gerber_single_quadrant.gtl')
|
||||
try:
|
||||
os.mkdir(cls.OUTDIR)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
def _checkResult(self, file):
|
||||
with open(file, 'r') as f:
|
||||
data = f.read()
|
||||
with open(os.path.join(self.EXPECTSDIR, os.path.basename(file)), 'r') as f:
|
||||
expect = f.read()
|
||||
self.assertEqual(data, expect)
|
||||
|
||||
def test_save(self):
|
||||
outfile=os.path.join(self.OUTDIR, self.OUTPREFIX + 'save.gtl')
|
||||
gerber = panelize.read(self.METRIC_FILE)
|
||||
gerber.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_to_inch(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'to_inch.gtl')
|
||||
gerber = panelize.read(self.METRIC_FILE)
|
||||
gerber.to_inch()
|
||||
gerber.format = (2,5)
|
||||
gerber.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_to_metric(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'to_metric.gtl')
|
||||
gerber = panelize.read(self.INCH_FILE)
|
||||
gerber.to_metric()
|
||||
gerber.format = (3, 4)
|
||||
gerber.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_offset(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'offset.gtl')
|
||||
gerber = panelize.read(self.METRIC_FILE)
|
||||
gerber.offset(11, 5)
|
||||
gerber.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_rotate(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'rotate.gtl')
|
||||
gerber = panelize.read(self.METRIC_FILE)
|
||||
gerber.rotate(20, (10,10))
|
||||
gerber.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
def test_single_quadrant(self):
|
||||
outfile = os.path.join(self.OUTDIR, self.OUTPREFIX + 'single_quadrant.gtl')
|
||||
gerber = panelize.read(self.SQ_FILE)
|
||||
gerber.write(outfile)
|
||||
self._checkResult(outfile)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue