From 045fdb7aea32e3f6359199861af8c4c60863e095 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Sat, 8 Feb 2025 13:17:07 -0700 Subject: [PATCH] Fix tests --- openc3-node/Dockerfile-ubi | 2 +- openc3/python/openc3/script/suite.py | 16 ++++++++-------- .../test/packets/parsers/test_state_parser.py | 2 +- openc3/python/test/packets/test_packet.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openc3-node/Dockerfile-ubi b/openc3-node/Dockerfile-ubi index c5660bb952..4d92655240 100644 --- a/openc3-node/Dockerfile-ubi +++ b/openc3-node/Dockerfile-ubi @@ -4,7 +4,7 @@ ARG OPENC3_TAG=latest FROM ${OPENC3_REGISTRY}/${OPENC3_NAMESPACE}/openc3-ruby-ubi:${OPENC3_TAG} -ENV NODEJS_VERSION=18 +ENV NODEJS_VERSION=20 ARG NPM_URL=https://registry.npmjs.org diff --git a/openc3/python/openc3/script/suite.py b/openc3/python/openc3/script/suite.py index 8167fe1a49..a4eba4656a 100644 --- a/openc3/python/openc3/script/suite.py +++ b/openc3/python/openc3/script/suite.py @@ -47,32 +47,32 @@ def plans(self): # Add a group to the suite def add_group(self, group_class): - if not isinstance(group_class, Group): - raise RuntimeError("add_group must be a Group not a string in Python") + if not issubclass(group_class, Group): + raise RuntimeError(f"add_group received with {group_class}({group_class.__class__}) but must subclass Group") if not self.scripts().get(group_class, None): self.scripts()[group_class] = group_class() self.plans().append(["GROUP", group_class, None]) # Add a script to the suite def add_script(self, group_class, script): - if not isinstance(group_class, Group): - raise RuntimeError("add_script first param must be a Group not a string in Python") + if not issubclass(group_class, Group): + raise RuntimeError(f"add_script received with {group_class}({group_class.__class__}) but must subclass Group") if not self.scripts().get(group_class, None): self.scripts()[group_class] = group_class() self.plans().append(["SCRIPT", group_class, script]) # Add a group setup to the suite def add_group_setup(self, group_class): - if not isinstance(group_class, Group): - raise RuntimeError("add_script must be a Group not a string in Python") + if not issubclass(group_class, Group): + raise RuntimeError(f"add_group_setup received with {group_class}({group_class.__class__}) but must subclass Group") if not self.scripts().get(group_class, None): self.scripts()[group_class] = group_class() self.plans().append(["GROUP_SETUP", group_class, None]) # Add a group teardown to the suite def add_group_teardown(self, group_class): - if not isinstance(group_class, Group): - raise RuntimeError("add_script must be a Group not a string in Python") + if not issubclass(group_class, Group): + raise RuntimeError(f"add_group_teardown received with {group_class}({group_class.__class__}) but must subclass Group") if not self.scripts().get(group_class, None): self.scripts()[group_class] = group_class() self.plans().append(["GROUP_TEARDOWN", group_class, None]) diff --git a/openc3/python/test/packets/parsers/test_state_parser.py b/openc3/python/test/packets/parsers/test_state_parser.py index 4575ccfadc..199c499362 100644 --- a/openc3/python/test/packets/parsers/test_state_parser.py +++ b/openc3/python/test/packets/parsers/test_state_parser.py @@ -264,7 +264,7 @@ def test_allows_hazardous_and_an_optional_description(self): tf.write(' STATE WORST 3 HAZARDOUS "Hazardous description"\n') tf.seek(0) self.pc.process_file(tf.name, "TGT1") - self.pc.commands["TGT1"]["PKT1"].buffer = "\x01" + self.pc.commands["TGT1"]["PKT1"].buffer = b"\x01" self.pc.commands["TGT1"]["PKT1"].check_limits self.assertIsNone( self.pc.commands["TGT1"]["PKT1"].items["ITEM1"].hazardous.get("GOOD") diff --git a/openc3/python/test/packets/test_packet.py b/openc3/python/test/packets/test_packet.py index 49b23d3c5d..774067ce73 100644 --- a/openc3/python/test/packets/test_packet.py +++ b/openc3/python/test/packets/test_packet.py @@ -382,7 +382,7 @@ def test_prevents_the_read_conversion_cache_from_being_corrupted(self): value += " more things" self.assertEqual(self.p.read_item(i, "WITH_UNITS"), "A str with units") - self.p.buffer = "\x00" + self.p.buffer = b"\x00" i.read_conversion = GenericConversion("['A', 'B', 'C']") value = self.p.read_item(i, "CONVERTED") self.assertEqual(value, ["A", "B", "C"])