def test_from_frequency(self): for channel, data in self.DATA: for navaid, frequency in data.items(): if frequency is None: continue with self.subTest(frequency=frequency): result = TACAN.from_frequency(frequency) self.assertEqual(result, (channel, navaid))
def test_to_frequency(self): for channel, data in self.DATA: for navaid, frequency in data.items(): with self.subTest(channel=channel, navaid=navaid): result = TACAN(channel).to_frequency(navaid) if frequency is None: self.assertIsNone(result) else: self.assertAlmostEqual(result, frequency, places=2)
def test_ordering(self): self.assertEqual(TACAN('1X'), TACAN('1X')) self.assertNotEqual(TACAN('1X'), TACAN('1Y')) self.assertLess(TACAN('1X'), TACAN('1Y')) self.assertLessEqual(TACAN('1X'), TACAN('1X')) self.assertGreater(TACAN('2X'), TACAN('1Y')) self.assertGreaterEqual(TACAN('2X'), TACAN('1X')) self.assertIs(TACAN('1X').__eq__(None), NotImplemented) self.assertIs(TACAN('1X').__ne__(None), NotImplemented) self.assertIs(TACAN('1X').__lt__(None), NotImplemented) self.assertIs(TACAN('1X').__le__(None), NotImplemented) self.assertIs(TACAN('1X').__gt__(None), NotImplemented) self.assertIs(TACAN('1X').__ge__(None), NotImplemented)
def test_repr(self): self.assertEqual(repr(TACAN('1X')), "TACAN('1X')")
def test_str(self): obj = TACAN('1X') self.assertEqual(str(obj), '1X') self.assertEqual(str(obj), obj.channel)
def test_immutable(self): with self.assertRaisesRegex(TypeError, r'^TACAN objects are immutable\.$'): TACAN('1X').channel = '1X'
def _test_constructor_error(self, *values, exception=None): for value in values: with self.subTest(value): with self.assertRaisesRegex(exception, f'^Invalid TACAN channel: {re.escape(repr(value))}$'): TACAN(value)