diff options
author | jaseg <git@jaseg.de> | 2021-06-06 13:28:42 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-06-06 13:28:42 +0200 |
commit | 889ea37d9b66cbfb7a61795c7750b9f4311faa3f (patch) | |
tree | 34db36bcdf0501445aaec30c845ed644537e638a /tests/test_rs274x.py | |
parent | 5a5ba2b709f01b2100cd767a25a41737541ad53c (diff) | |
parent | 71c371ca680483aa9ef18d2998832460dd43abdf (diff) | |
download | gerbonara-889ea37d9b66cbfb7a61795c7750b9f4311faa3f.tar.gz gerbonara-889ea37d9b66cbfb7a61795c7750b9f4311faa3f.tar.bz2 gerbonara-889ea37d9b66cbfb7a61795c7750b9f4311faa3f.zip |
Graft pcb-tools-extension master onto gerbonara main
Diffstat (limited to 'tests/test_rs274x.py')
-rw-r--r-- | tests/test_rs274x.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/test_rs274x.py b/tests/test_rs274x.py new file mode 100644 index 0000000..dbb5f62 --- /dev/null +++ b/tests/test_rs274x.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com> + +import os +import unittest +import gerberex + +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 = gerberex.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 = gerberex.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 = gerberex.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 = gerberex.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 = gerberex.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 = gerberex.read(self.SQ_FILE) + gerber.write(outfile) + self._checkResult(outfile) + +if __name__ == '__main__': + unittest.main() |