summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-06-13 15:13:29 +0200
committerjaseg <git@jaseg.de>2021-06-13 15:13:29 +0200
commit4bb99811221d0cbbf52e6ab59a76bbe6bd8fba6c (patch)
tree9b491f11c2c77c5e8de8b74eed75162838c5dbf5
parent83e498b8917e0b3287871c27a4acc95634acab2e (diff)
downloadgerbonara-4bb99811221d0cbbf52e6ab59a76bbe6bd8fba6c.tar.gz
gerbonara-4bb99811221d0cbbf52e6ab59a76bbe6bd8fba6c.tar.bz2
gerbonara-4bb99811221d0cbbf52e6ab59a76bbe6bd8fba6c.zip
Make pcb-tools pytest pass without warnings
-rw-r--r--gerbonara/gerber/common.py2
-rwxr-xr-xgerbonara/gerber/excellon.py6
-rw-r--r--gerbonara/gerber/ipc356.py14
-rw-r--r--gerbonara/gerber/panelize/common.py2
-rw-r--r--gerbonara/gerber/primitives.py1
-rw-r--r--gerbonara/gerber/render/cairo_backend.py2
-rw-r--r--gerbonara/gerber/rs274x.py2
-rw-r--r--gerbonara/gerber/tests/test_cairo_backend.py2
-rw-r--r--gerbonara/gerber/tests/test_common.py4
-rw-r--r--gerbonara/gerber/tests/test_excellon.py6
10 files changed, 22 insertions, 19 deletions
diff --git a/gerbonara/gerber/common.py b/gerbonara/gerber/common.py
index f496809..12b87c4 100644
--- a/gerbonara/gerber/common.py
+++ b/gerbonara/gerber/common.py
@@ -36,7 +36,7 @@ def read(filename):
CncFile object representing the file, either GerberFile, ExcellonFile,
or IPCNetlist. Returns None if file is not of the proper type.
"""
- with open(filename, 'rU') as f:
+ with open(filename, 'r') as f:
data = f.read()
return loads(data, filename)
diff --git a/gerbonara/gerber/excellon.py b/gerbonara/gerber/excellon.py
index 5ab062a..5a9d16d 100755
--- a/gerbonara/gerber/excellon.py
+++ b/gerbonara/gerber/excellon.py
@@ -54,7 +54,7 @@ def read(filename):
"""
# File object should use settings from source file by default.
- with open(filename, 'rU') as f:
+ with open(filename, 'r') as f:
data = f.read()
settings = FileSettings(**detect_excellon_format(data))
return ExcellonParser(settings).parse(filename)
@@ -426,7 +426,7 @@ class ExcellonParser(object):
return len(self.hits)
def parse(self, filename):
- with open(filename, 'rU') as f:
+ with open(filename, 'r') as f:
data = f.read()
return self.parse_raw(data, filename)
@@ -818,7 +818,7 @@ def detect_excellon_format(data=None, filename=None):
if data is None and filename is None:
raise ValueError('Either data or filename arguments must be provided')
if data is None:
- with open(filename, 'rU') as f:
+ with open(filename, 'r') as f:
data = f.read()
# Check for obvious clues:
diff --git a/gerbonara/gerber/ipc356.py b/gerbonara/gerber/ipc356.py
index 9337a99..55c079a 100644
--- a/gerbonara/gerber/ipc356.py
+++ b/gerbonara/gerber/ipc356.py
@@ -163,7 +163,7 @@ class IPCNetlistParser(object):
return FileSettings(units=self.units, angle_units=self.angle_units)
def parse(self, filename):
- with open(filename, 'rU') as f:
+ with open(filename, 'r') as f:
data = f.read()
return self.parse_raw(data, filename)
@@ -382,8 +382,8 @@ class IPC356_Outline(object):
coord_strings = line.strip().split()[1:]
for coord in coord_strings:
coord_dict = _COORD.match(coord).groupdict()
- x = int(coord_dict['x']) if coord_dict['x'] is not '' else x
- y = int(coord_dict['y']) if coord_dict['y'] is not '' else y
+ x = int(coord_dict['x']) if coord_dict['x'] != '' else x
+ y = int(coord_dict['y']) if coord_dict['y'] != '' else y
points.append((x * scale, y * scale))
return cls(type, points)
@@ -412,9 +412,9 @@ class IPC356_Conductor(object):
x = 0
y = 0
x = int(aperture_dict['x']) * \
- scale if aperture_dict['x'] is not '' else None
+ scale if aperture_dict['x'] != '' else None
y = int(aperture_dict['y']) * \
- scale if aperture_dict['y'] is not '' else None
+ scale if aperture_dict['y'] != '' else None
aperture = (x, y)
# Parse out conductor shapes
@@ -428,8 +428,8 @@ class IPC356_Conductor(object):
coords = rshape.split()
for coord in coords:
coord_dict = _COORD.match(coord).groupdict()
- x = int(coord_dict['x']) if coord_dict['x'] is not '' else x
- y = int(coord_dict['y']) if coord_dict['y'] is not '' else y
+ x = int(coord_dict['x']) if coord_dict['x'] != '' else x
+ y = int(coord_dict['y']) if coord_dict['y'] != '' else y
shape.append((x * scale, y * scale))
shapes.append(tuple(shape))
return cls(net_name, layer, aperture, tuple(shapes))
diff --git a/gerbonara/gerber/panelize/common.py b/gerbonara/gerber/panelize/common.py
index 03bf9b0..ac25138 100644
--- a/gerbonara/gerber/panelize/common.py
+++ b/gerbonara/gerber/panelize/common.py
@@ -15,7 +15,7 @@ from . import excellon
from . import dxf
def read(filename, format=None):
- with open(filename, 'rU') as f:
+ with open(filename, 'r') as f:
data = f.read()
return loads(data, filename, format=format)
diff --git a/gerbonara/gerber/primitives.py b/gerbonara/gerber/primitives.py
index 757f117..fa067a1 100644
--- a/gerbonara/gerber/primitives.py
+++ b/gerbonara/gerber/primitives.py
@@ -1687,6 +1687,7 @@ class Slot(Primitive):
class TestRecord(Primitive):
""" Netlist Test record
"""
+ __test__ = False # This is not a PyTest unit test.
def __init__(self, position, net_name, layer, **kwargs):
super(TestRecord, self).__init__(**kwargs)
diff --git a/gerbonara/gerber/render/cairo_backend.py b/gerbonara/gerber/render/cairo_backend.py
index 03366f6..cb2f37c 100644
--- a/gerbonara/gerber/render/cairo_backend.py
+++ b/gerbonara/gerber/render/cairo_backend.py
@@ -136,8 +136,10 @@ class GerberCairoContext(GerberContext):
is_svg = os.path.splitext(filename.lower())[1] == '.svg'
except:
is_svg = False
+
if verbose:
print('[Render]: Writing image to {}'.format(filename))
+
if is_svg:
self.surface.finish()
self.surface_buffer.flush()
diff --git a/gerbonara/gerber/rs274x.py b/gerbonara/gerber/rs274x.py
index afdf45f..4852ed2 100644
--- a/gerbonara/gerber/rs274x.py
+++ b/gerbonara/gerber/rs274x.py
@@ -260,7 +260,7 @@ class GerberParser(object):
def parse(self, filename):
self.filename = filename
- with open(filename, "rU") as fp:
+ with open(filename, "r") as fp:
data = fp.read()
return self.parse_raw(data, filename)
diff --git a/gerbonara/gerber/tests/test_cairo_backend.py b/gerbonara/gerber/tests/test_cairo_backend.py
index 51007a9..3dc783d 100644
--- a/gerbonara/gerber/tests/test_cairo_backend.py
+++ b/gerbonara/gerber/tests/test_cairo_backend.py
@@ -221,7 +221,7 @@ def _test_render(gerber_path, png_expected_path, create_output_path=None):
ctx = GerberCairoContext()
gerber.render(ctx)
- actual_bytes = ctx.dump(None)
+ actual_bytes = ctx.dump_str()
# If we want to write the file bytes, do it now. This happens
if create_output_path:
diff --git a/gerbonara/gerber/tests/test_common.py b/gerbonara/gerber/tests/test_common.py
index a6b1264..e4c023c 100644
--- a/gerbonara/gerber/tests/test_common.py
+++ b/gerbonara/gerber/tests/test_common.py
@@ -24,9 +24,9 @@ def test_file_type_detection():
def test_load_from_string():
- with open(NCDRILL_FILE, "rU") as f:
+ with open(NCDRILL_FILE, "r") as f:
ncdrill = loads(f.read())
- with open(TOP_COPPER_FILE, "rU") as f:
+ with open(TOP_COPPER_FILE, "r") as f:
top_copper = loads(f.read())
assert isinstance(ncdrill, ExcellonFile)
assert isinstance(top_copper, GerberFile)
diff --git a/gerbonara/gerber/tests/test_excellon.py b/gerbonara/gerber/tests/test_excellon.py
index d6e83cc..ef34f67 100644
--- a/gerbonara/gerber/tests/test_excellon.py
+++ b/gerbonara/gerber/tests/test_excellon.py
@@ -17,7 +17,7 @@ NCDRILL_FILE = os.path.join(os.path.dirname(__file__), "resources/ncdrill.DRD")
def test_format_detection():
""" Test file type detection
"""
- with open(NCDRILL_FILE, "rU") as f:
+ with open(NCDRILL_FILE, "r") as f:
data = f.read()
settings = detect_excellon_format(data)
assert settings["format"] == (2, 4)
@@ -36,9 +36,9 @@ def test_read():
def test_write():
ncdrill = read(NCDRILL_FILE)
ncdrill.write("test.ncd")
- with open(NCDRILL_FILE, "rU") as src:
+ with open(NCDRILL_FILE, "r") as src:
srclines = src.readlines()
- with open("test.ncd", "rU") as res:
+ with open("test.ncd", "r") as res:
for idx, line in enumerate(res):
assert line.strip() == srclines[idx].strip()
os.remove("test.ncd")