diff options
author | opiopan <opiopan@gmail.com> | 2019-04-07 22:22:33 +0900 |
---|---|---|
committer | opiopan <opiopan@gmail.com> | 2019-04-07 22:22:33 +0900 |
commit | e3c59e39cf9bc64ce9d76c324b82956a65515f16 (patch) | |
tree | 96a87bab252420c14d955ad4c1d59a5101b77cf4 /tests/test_excellon.py | |
parent | d53293a609a83aa945af6864285b90d36bcbdd69 (diff) | |
download | gerbonara-e3c59e39cf9bc64ce9d76c324b82956a65515f16.tar.gz gerbonara-e3c59e39cf9bc64ce9d76c324b82956a65515f16.tar.bz2 gerbonara-e3c59e39cf9bc64ce9d76c324b82956a65515f16.zip |
expand test and fix many issues
Diffstat (limited to 'tests/test_excellon.py')
-rw-r--r-- | tests/test_excellon.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/test_excellon.py b/tests/test_excellon.py new file mode 100644 index 0000000..36093cd --- /dev/null +++ b/tests/test_excellon.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com> + +import os +import unittest +import gerberex + + +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 = gerberex.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 = gerberex.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 = gerberex.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 = gerberex.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 = gerberex.read(self.METRIC_FILE) + drill.rotate(20, (10, 10)) + drill.write(outfile) + self._checkResult(outfile) + + +if __name__ == '__main__': + unittest.main() |