summaryrefslogtreecommitdiff
path: root/gerber/tests/test_cam.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2019-11-26 00:37:41 -0300
committerGitHub <noreply@github.com>2019-11-26 00:37:41 -0300
commitef589a064015de3a1ce6487dbb56b99332673e9d (patch)
tree5dd7ec0c1a86cff0f9459b90f0d2aeca768182c0 /gerber/tests/test_cam.py
parent404384cf912fa082c120ba5be81973ea097958fc (diff)
downloadgerbonara-ef589a064015de3a1ce6487dbb56b99332673e9d.tar.gz
gerbonara-ef589a064015de3a1ce6487dbb56b99332673e9d.tar.bz2
gerbonara-ef589a064015de3a1ce6487dbb56b99332673e9d.zip
Migrate to pytest (#111)
* Migrate to pytest All tests were update to use pytest. Tests were alse black formatted. Eventually all code will be black formatted but need to merge some PRs first.
Diffstat (limited to 'gerber/tests/test_cam.py')
-rw-r--r--gerber/tests/test_cam.py142
1 files changed, 72 insertions, 70 deletions
diff --git a/gerber/tests/test_cam.py b/gerber/tests/test_cam.py
index ba5e99d..8a71a32 100644
--- a/gerber/tests/test_cam.py
+++ b/gerber/tests/test_cam.py
@@ -3,56 +3,57 @@
# Author: Hamilton Kibbe <ham@hamiltonkib.be>
+import pytest
+
from ..cam import CamFile, FileSettings
-from .tests import *
def test_filesettings_defaults():
""" Test FileSettings default values
"""
fs = FileSettings()
- assert_equal(fs.format, (2, 5))
- assert_equal(fs.notation, 'absolute')
- assert_equal(fs.zero_suppression, 'trailing')
- assert_equal(fs.units, 'inch')
+ assert fs.format == (2, 5)
+ assert fs.notation == "absolute"
+ assert fs.zero_suppression == "trailing"
+ assert fs.units == "inch"
def test_filesettings_dict():
""" Test FileSettings Dict
"""
fs = FileSettings()
- assert_equal(fs['format'], (2, 5))
- assert_equal(fs['notation'], 'absolute')
- assert_equal(fs['zero_suppression'], 'trailing')
- assert_equal(fs['units'], 'inch')
+ assert fs["format"] == (2, 5)
+ assert fs["notation"] == "absolute"
+ assert fs["zero_suppression"] == "trailing"
+ assert fs["units"] == "inch"
def test_filesettings_assign():
""" Test FileSettings attribute assignment
"""
fs = FileSettings()
- fs.units = 'test1'
- fs.notation = 'test2'
- fs.zero_suppression = 'test3'
- fs.format = 'test4'
- assert_equal(fs.units, 'test1')
- assert_equal(fs.notation, 'test2')
- assert_equal(fs.zero_suppression, 'test3')
- assert_equal(fs.format, 'test4')
+ fs.units = "test1"
+ fs.notation = "test2"
+ fs.zero_suppression = "test3"
+ fs.format = "test4"
+ assert fs.units == "test1"
+ assert fs.notation == "test2"
+ assert fs.zero_suppression == "test3"
+ assert fs.format == "test4"
def test_filesettings_dict_assign():
""" Test FileSettings dict-style attribute assignment
"""
fs = FileSettings()
- fs['units'] = 'metric'
- fs['notation'] = 'incremental'
- fs['zero_suppression'] = 'leading'
- fs['format'] = (1, 2)
- assert_equal(fs.units, 'metric')
- assert_equal(fs.notation, 'incremental')
- assert_equal(fs.zero_suppression, 'leading')
- assert_equal(fs.format, (1, 2))
+ fs["units"] = "metric"
+ fs["notation"] = "incremental"
+ fs["zero_suppression"] = "leading"
+ fs["format"] = (1, 2)
+ assert fs.units == "metric"
+ assert fs.notation == "incremental"
+ assert fs.zero_suppression == "leading"
+ assert fs.format == (1, 2)
def test_camfile_init():
@@ -65,7 +66,7 @@ def test_camfile_settings():
""" Test CamFile Default Settings
"""
cf = CamFile()
- assert_equal(cf.settings, FileSettings())
+ assert cf.settings == FileSettings()
def test_bounds_override_smoketest():
@@ -77,73 +78,74 @@ def test_zeros():
""" Test zero/zero_suppression interaction
"""
fs = FileSettings()
- assert_equal(fs.zero_suppression, 'trailing')
- assert_equal(fs.zeros, 'leading')
+ assert fs.zero_suppression == "trailing"
+ assert fs.zeros == "leading"
- fs['zero_suppression'] = 'leading'
- assert_equal(fs.zero_suppression, 'leading')
- assert_equal(fs.zeros, 'trailing')
+ fs["zero_suppression"] = "leading"
+ assert fs.zero_suppression == "leading"
+ assert fs.zeros == "trailing"
- fs.zero_suppression = 'trailing'
- assert_equal(fs.zero_suppression, 'trailing')
- assert_equal(fs.zeros, 'leading')
+ fs.zero_suppression = "trailing"
+ assert fs.zero_suppression == "trailing"
+ assert fs.zeros == "leading"
- fs['zeros'] = 'trailing'
- assert_equal(fs.zeros, 'trailing')
- assert_equal(fs.zero_suppression, 'leading')
+ fs["zeros"] = "trailing"
+ assert fs.zeros == "trailing"
+ assert fs.zero_suppression == "leading"
- fs.zeros = 'leading'
- assert_equal(fs.zeros, 'leading')
- assert_equal(fs.zero_suppression, 'trailing')
+ fs.zeros = "leading"
+ assert fs.zeros == "leading"
+ assert fs.zero_suppression == "trailing"
- fs = FileSettings(zeros='leading')
- assert_equal(fs.zeros, 'leading')
- assert_equal(fs.zero_suppression, 'trailing')
+ fs = FileSettings(zeros="leading")
+ assert fs.zeros == "leading"
+ assert fs.zero_suppression == "trailing"
- fs = FileSettings(zero_suppression='leading')
- assert_equal(fs.zeros, 'trailing')
- assert_equal(fs.zero_suppression, 'leading')
+ fs = FileSettings(zero_suppression="leading")
+ assert fs.zeros == "trailing"
+ assert fs.zero_suppression == "leading"
- fs = FileSettings(zeros='leading', zero_suppression='trailing')
- assert_equal(fs.zeros, 'leading')
- assert_equal(fs.zero_suppression, 'trailing')
+ fs = FileSettings(zeros="leading", zero_suppression="trailing")
+ assert fs.zeros == "leading"
+ assert fs.zero_suppression == "trailing"
- fs = FileSettings(zeros='trailing', zero_suppression='leading')
- assert_equal(fs.zeros, 'trailing')
- assert_equal(fs.zero_suppression, 'leading')
+ fs = FileSettings(zeros="trailing", zero_suppression="leading")
+ assert fs.zeros == "trailing"
+ assert fs.zero_suppression == "leading"
def test_filesettings_validation():
""" Test FileSettings constructor argument validation
"""
# absolute-ish is not a valid notation
- assert_raises(ValueError, FileSettings, 'absolute-ish',
- 'inch', None, (2, 5), None)
+ pytest.raises(ValueError, FileSettings, "absolute-ish", "inch", None, (2, 5), None)
# degrees kelvin isn't a valid unit for a CAM file
- assert_raises(ValueError, FileSettings, 'absolute',
- 'degrees kelvin', None, (2, 5), None)
+ pytest.raises(
+ ValueError, FileSettings, "absolute", "degrees kelvin", None, (2, 5), None
+ )
- assert_raises(ValueError, FileSettings, 'absolute',
- 'inch', 'leading', (2, 5), 'leading')
+ pytest.raises(
+ ValueError, FileSettings, "absolute", "inch", "leading", (2, 5), "leading"
+ )
# Technnically this should be an error, but Eangle files often do this incorrectly so we
# allow it
- #assert_raises(ValueError, FileSettings, 'absolute',
+ # pytest.raises(ValueError, FileSettings, 'absolute',
# 'inch', 'following', (2, 5), None)
- assert_raises(ValueError, FileSettings, 'absolute',
- 'inch', None, (2, 5), 'following')
- assert_raises(ValueError, FileSettings, 'absolute',
- 'inch', None, (2, 5, 6), None)
+ pytest.raises(
+ ValueError, FileSettings, "absolute", "inch", None, (2, 5), "following"
+ )
+ pytest.raises(ValueError, FileSettings, "absolute", "inch", None, (2, 5, 6), None)
def test_key_validation():
fs = FileSettings()
- assert_raises(KeyError, fs.__getitem__, 'octopus')
- assert_raises(KeyError, fs.__setitem__, 'octopus', 'do not care')
- assert_raises(ValueError, fs.__setitem__, 'notation', 'absolute-ish')
- assert_raises(ValueError, fs.__setitem__, 'units', 'degrees kelvin')
- assert_raises(ValueError, fs.__setitem__, 'zero_suppression', 'following')
- assert_raises(ValueError, fs.__setitem__, 'zeros', 'following')
- assert_raises(ValueError, fs.__setitem__, 'format', (2, 5, 6))
+ pytest.raises(KeyError, fs.__getitem__, "octopus")
+ pytest.raises(KeyError, fs.__setitem__, "octopus", "do not care")
+ pytest.raises(ValueError, fs.__setitem__, "notation", "absolute-ish")
+ pytest.raises(ValueError, fs.__setitem__, "units", "degrees kelvin")
+ pytest.raises(ValueError, fs.__setitem__, "zero_suppression", "following")
+ pytest.raises(ValueError, fs.__setitem__, "zeros", "following")
+ pytest.raises(ValueError, fs.__setitem__, "format", (2, 5, 6))