Fix bug in GcodeCommand constructor

This commit is contained in:
Gina Häußge committed 2018-05-30 19:12:30 +02:00
1 parent 9bc8638d80
commit ba00b4d675
2 files changed
+14 -6

No files matched your search

@@ -89,16 +89,16 @@ class GcodeCommand(Command):
self.param = kwargs.pop(b"param", None)
self.original = kwargs.pop(b"original", None)
if self.original is None:
line = self._to_line()
else:
line = self.original
type = kwargs.pop(b"type", None)
tags = kwargs.pop(b"tags", None)
self.args = kwargs
if self.original is None:
line = self._to_line()
else:
line = self.original
super(GcodeCommand, self).__init__(line, type=type, tags=tags)
self._repr = self._to_repr()
@@ -114,7 +114,7 @@ class GcodeCommand(Command):
def _to_line(self):
attr = []
for key in string.ascii_lowercase:
value = getattr(self, key, None)
value = self.args.get(key, None)
if value is not None:
if value is True:
attr.append(key.upper())
@@ -47,3 +47,11 @@ class GcodeCommandTest(unittest.TestCase):
def test_repr(self, line, expected):
gcode = GcodeCommand.from_line(line)
self.assertEqual(expected, repr(gcode))
@ddt.data(
("M104", dict(s=210.0), "M104 S210.0")
)
@ddt.unpack
def test_constructor(self, code, kwargs, expected):
gcode = GcodeCommand(code, **kwargs)
self.assertEqual(expected, str(gcode))