コード例 #1
0
 def test_read_error_code(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     r = pvp.read_error_code(s, 1)
     self.assertEqual(r, pvp.ErrorCode.NO_ERROR)
     s = mock.Serial(
         mock.PPT100(err_state=pvp.ErrorCode.DEFECTIVE_TRANSMITTER), "COM1")
     r = pvp.read_error_code(s, 1)
     self.assertEqual(r, pvp.ErrorCode.DEFECTIVE_TRANSMITTER)
     s = mock.Serial(mock.PPT100(err_state=pvp.ErrorCode.DEFECTIVE_MEMORY),
                     "COM1")
     r = pvp.read_error_code(s, 1)
     self.assertEqual(r, pvp.ErrorCode.DEFECTIVE_MEMORY)
コード例 #2
0
 def test_io_readline(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     sio = io.TextIOWrapper(io.BufferedRWPair(s, s), newline="\r")
     sio.write("0010073902=?114\r")
     sio.flush()
     r = sio.readline()
     self.assertEqual(r, "0011073906NO_DEF198\r")
コード例 #3
0
 def test_flush(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     s.flush()
コード例 #4
0
 def test_wrong_baudrate(self):
     s = mock.Serial(mock.PPT100(), "COM1", 19200)
     s.write(b"0010073902=?114\r")
     r = s.read(1)
     self.assertEqual(r, b"")
コード例 #5
0
 def test_read(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     s.write(b"0010073902=?114\r")
     r = s.read(1)
     self.assertEqual(r, b"0")
コード例 #6
0
 def test_wrong_type(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     with self.assertRaises(TypeError) as context:
         s.write("blah blah blah")
コード例 #7
0
 def test_write(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     r = s.write(b"test")
     self.assertEqual(r, 4)
コード例 #8
0
 def test_write_correction_value(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     pvp.write_correction_value(s, 1, 1.0)
コード例 #9
0
 def test_read_correction_value(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     r = pvp.read_correction_value(s, 1)
     self.assertEqual(r, 1.0)
コード例 #10
0
 def test_write_pressure_setpoint(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     pvp.write_pressure_setpoint(s, 1, 0)
     pvp.write_pressure_setpoint(s, 1, 1)
     with self.assertRaises(ValueError) as context:
         pvp.write_pressure_setpoint(s, 1, 2)
コード例 #11
0
 def test_read_pressure(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     r = pvp.read_pressure(s, 1)
     self.assertEqual(r, 1.0)
コード例 #12
0
 def test_read_gauge_type(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     r = pvp.read_gauge_type(s, 1)
     self.assertEqual(r, "PPT 100")
コード例 #13
0
 def test_read_software_version(self):
     s = mock.Serial(mock.PPT100(), "COM1")
     r = pvp.read_software_version(s, 1)
     self.assertEqual(r, (1, 1, 0))