aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-12-12 13:00:00 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2017-12-15 07:30:35 +0100
commitdce92efdbc3f689197c6d46ff3f37cecb7c81a40 (patch)
tree8cf1a03a6d717df6aa87f0c7cad4bffbac2a362c
parent102614dc8fe2f5aefd0fd92c1b6e48107a9629b0 (diff)
downloadee-python-dce92efdbc3f689197c6d46ff3f37cecb7c81a40.tar.gz
ee-python-dce92efdbc3f689197c6d46ff3f37cecb7c81a40.tar.bz2
ee-python-dce92efdbc3f689197c6d46ff3f37cecb7c81a40.tar.xz
ee-python-dce92efdbc3f689197c6d46ff3f37cecb7c81a40.zip
o Adding a test for kicad-make-pos.
-rw-r--r--test/tool/test_kicad_make_pos.py27
-rw-r--r--test/utils.py26
2 files changed, 53 insertions, 0 deletions
diff --git a/test/tool/test_kicad_make_pos.py b/test/tool/test_kicad_make_pos.py
new file mode 100644
index 0000000..447b497
--- /dev/null
+++ b/test/tool/test_kicad_make_pos.py
@@ -0,0 +1,27 @@
+import utils
+import argparse
+import os.path
+from io import StringIO
+
+basedir = os.path.dirname(os.path.abspath(__file__))
+
+def test_basic():
+ argv = [
+ "ee",
+ "--kicad-pcb",
+ os.path.join(basedir, "../kicad_pcb/parser-1.kicad_pcb")
+ ]
+ buf = StringIO()
+ try:
+ with utils.make_env(argv=argv, stdout=buf):
+ import ee.tools.kicad_make_pos
+ except SystemExit as e:
+ raise e
+ finally:
+ print("Output")
+ buf.seek(0)
+ count = 0
+ for l in buf.readlines():
+ print(l.rstrip())
+ count = count + 1
+ assert count > 3
diff --git a/test/utils.py b/test/utils.py
new file mode 100644
index 0000000..5c67f92
--- /dev/null
+++ b/test/utils.py
@@ -0,0 +1,26 @@
+import sys
+
+class make_env(object):
+ def __init__(self, argv=None, stdout=None):
+ self.argv = argv
+ self.stdout = stdout
+
+ def __enter__(self):
+ self.old_argv = sys.argv
+ if self.argv:
+ sys.argv = self.argv
+
+ self.old_stdout = sys.stdout
+ self.old_stderr = sys.stderr
+ if self.stdout:
+ sys.stdout = self.stdout
+ sys.stderr = self.stdout
+
+ def __exit__(self, *args):
+ if self.old_argv:
+ sys.argv = self.old_argv
+
+ if self.old_stdout:
+ sys.stdout = self.old_stdout
+ if self.old_stderr:
+ sys.stderr = self.old_stderr