From 234ccec69a6430e9468e42b55ff636163d86986e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sat, 10 Aug 2013 22:24:41 +0100 Subject: test_otultra2: factor out setting of returned serial string. --- test/test_otultra2.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/test_otultra2.py') diff --git a/test/test_otultra2.py b/test/test_otultra2.py index 9080c79..5474c1f 100644 --- a/test/test_otultra2.py +++ b/test/test_otultra2.py @@ -28,41 +28,41 @@ class TestOTUltra2(unittest.TestCase): self.device = otultra2.Device('mockdevice') + def _set_return_string(self, string): + self.mock_readline.return_value = bytes(string, 'ascii') + def testMissingChecksum(self): - self.mock_readline.return_value = bytes('INVALID', 'ascii') + self._set_return_string('INVALID') self.assertRaises(lifescan_common.MissingChecksum, self.device.get_serial_number) def testShortResponse(self): - self.mock_readline.return_value = bytes('.\r', 'ascii') + self._set_return_string('.\r') self.assertRaises(exceptions.InvalidResponse, self.device.get_serial_number) def testInvalidResponse(self): - self.mock_readline.return_value = bytes('% 2500\r', 'ascii') + self._set_return_string('% 2500\r') self.assertRaises(exceptions.InvalidResponse, self.device.get_serial_number) def testInvalidSerialNumber(self): - self.mock_readline.return_value = bytes( - '@ "12345678O" 0297\r', 'ascii') + self._set_return_string('@ "12345678O" 0297\r') self.assertRaises(lifescan_common.InvalidSerialNumber, self.device.get_serial_number) def testInvalidChecksum(self): - self.mock_readline.return_value = bytes( - '% 1337\r', 'ascii') + self._set_return_string('% 1337\r') self.assertRaises(lifescan_common.InvalidChecksum, self.device.get_serial_number) def testBrokenChecksum(self): - self.mock_readline.return_value = bytes( - '% 13AZ\r', 'ascii') + self._set_return_string('% 13AZ\r') self.assertRaises(lifescan_common.MissingChecksum, self.device.get_serial_number) -- cgit v1.2.3