def setUp(self):
        #Fixtures
        self.test_temp_str = '{"Ta":22.51, "To":[20.27,20.50,19.27,19.62,20.07,19.25,20.29,19.98,20.83,19.63,19.18,' \
                           '19.76,20.49,20.74,19.87,19.92,19.80,19.26,20.46,19.71,19.93,19.47,19.39,19.44,19.62,' \
                           '20.96,21.69,21.14,26.39,24.74,25.16,26.20,26.75,26.74,26.76,26.91,26.09,27.12,26.79,' \
                           '26.20,27.24,26.20,25.89,26.26,26.94,26.94,24.92,25.96,26.77,26.72,25.36,25.26,26.54,' \
                           '26.45,26.14,26.58,23.69,26.38,26.71,26.82,20.41,21.05,21.07,22.82]}\r\n'

        self.test_temp = [20.27, 20.50, 19.27, 19.62, 20.07, 19.25, 20.29, 19.98, 20.83, 19.63, 19.18, 19.76, 20.49,
                         20.74, 19.87, 19.92, 19.80, 19.26, 20.46, 19.71, 19.93, 19.47, 19.39, 19.44, 19.62, 20.96,
                         21.69, 21.14, 26.39, 24.74, 25.16, 26.20, 26.75, 26.74, 26.76, 26.91, 26.09, 27.12, 26.79,
                         26.20, 27.24, 26.20, 25.89, 26.26, 26.94, 26.94, 24.92, 25.96, 26.77, 26.72, 25.36, 25.26,
                         26.54, 26.45, 26.14, 26.58, 23.69, 26.38, 26.71, 26.82, 20.41, 21.05, 21.07, 22.82]
        self.test_ambient_temp = 22.51

        self.test_temp_str2 = '{"Ta":30.73, "To":[30.81,23.60,23.04,21.81,22.49,22.51,22.02,22.48,21.56,21.65,' \
                            '21.65,21.51,22.08,22.18,22.14,21.58,22.54,22.21,22.23,22.54,21.77,21.88,21.86,' \
                            '22.58,21.03,21.55,21.21,21.78,21.08,21.57,21.57,21.44,21.46,22.63,21.94,22.61,' \
                            '21.48,21.93,21.93,22.22,21.46,21.92,21.91,21.02,21.44,21.90,21.15,21.39,20.55,' \
                            '21.88,21.86,22.18,21.75,20.71,21.07,20.87,21.70,20.96,20.17,21.31,21.62,19.94,' \
                            '20.43,20.69]}\r\n'

        self.test_ambient_temp2 = 30.73

        #Use posix.openpty to create dummy Serial Port for Testing
        #http://stackoverflow.com/questions/2174071/how-to-use-dev-ptmx-for-create-a-virtual-serial-port
        self.fd_master, self.fd_slave = posix.openpty()
        self.test_sensor_config = MLX90620SensorProperties(arg_name='TestNode',
                                                           arg_port=os.ttyname(self.fd_slave),
                                                           arg_time_between_ambient_temp=0.2)
        #print self.test_sensor_config.__dict__
        self.test_sensor = MLX90620(self.test_sensor_config)
示例#2
0
 def test_ignore_ioerror_in_readall_if_nonempty_result(self):
     # this is the behavior of regular files in CPython 2.7, as
     # well as of _io.FileIO at least in CPython 3.3.  This is
     # *not* the behavior of _io.FileIO in CPython 3.4 or 3.5;
     # see CPython's issue #21090.
     import sys
     try:
         from posix import openpty, fdopen, write, close
     except ImportError:
         skip('no openpty on this platform')
     if 'gnukfreebsd' in sys.platform:
         skip('close() hangs forever on kFreeBSD')
     read_fd, write_fd = openpty()
     write(write_fd, 'Abc\n')
     close(write_fd)
     f = fdopen(read_fd)
     # behavior on Linux: f.read() returns 'Abc\r\n', then the next time
     # it raises IOError.  Behavior on OS/X (Python 2.7.5): the close()
     # above threw away the buffer, and f.read() always returns ''.
     if sys.platform.startswith('linux'):
         s = f.read()
         assert s == 'Abc\r\n'
         raises(IOError, f.read)
     else:
         s = f.read()
         assert s == ''
         s = f.read()
         assert s == ''
     f.close()
示例#3
0
 def test_ignore_ioerror_in_readall_if_nonempty_result(self):
     # this is the behavior of regular files in CPython 2.7, as
     # well as of _io.FileIO at least in CPython 3.3.  This is
     # *not* the behavior of _io.FileIO in CPython 3.4 or 3.5;
     # see CPython's issue #21090.
     import sys
     try:
         from posix import openpty, fdopen, write, close
     except ImportError:
         skip('no openpty on this platform')
     read_fd, write_fd = openpty()
     write(write_fd, 'Abc\n')
     close(write_fd)
     f = fdopen(read_fd)
     # behavior on Linux: f.read() returns 'Abc\r\n', then the next time
     # it raises IOError.  Behavior on OS/X (Python 2.7.5): the close()
     # above threw away the buffer, and f.read() always returns ''.
     if sys.platform.startswith('linux'):
         s = f.read()
         assert s == 'Abc\r\n'
         raises(IOError, f.read)
     else:
         s = f.read()
         assert s == ''
         s = f.read()
         assert s == ''
     f.close()
示例#4
0
文件: test_file.py 项目: juokaz/pypy
 def test_ignore_ioerror_in_readall_if_nonempty_result(self):
     # this is the behavior of regular files in CPython 2.7, as
     # well as of _io.FileIO at least in CPython 3.3.  This is
     # *not* the behavior of _io.FileIO in CPython 3.4 or 3.5;
     # see CPython's issue #21090.
     try:
         from posix import openpty, fdopen, write, close
     except ImportError:
         skip('no openpty on this platform')
     read_fd, write_fd = openpty()
     write(write_fd, 'Abc\n')
     close(write_fd)
     f = fdopen(read_fd)
     s = f.read()
     assert s == 'Abc\r\n'
     raises(IOError, f.read)
     f.close()
示例#5
0
文件: test_file.py 项目: bukzor/pypy
 def test_ignore_ioerror_in_readall_if_nonempty_result(self):
     # this is the behavior of regular files in CPython 2.7, as
     # well as of _io.FileIO at least in CPython 3.3.  This is
     # *not* the behavior of _io.FileIO in CPython 3.4 or 3.5;
     # see CPython's issue #21090.
     try:
         from posix import openpty, fdopen, write, close
     except ImportError:
         skip('no openpty on this platform')
     read_fd, write_fd = openpty()
     write(write_fd, 'Abc\n')
     close(write_fd)
     f = fdopen(read_fd)
     s = f.read()
     assert s == 'Abc\r\n'
     raises(IOError, f.read)
     f.close()
示例#6
0
    def setUp(self):
        #Fixtures
        self.test_temp_str = '{"Ta":22.51, "To":[20.27,20.50,19.27,19.62,20.07,19.25,20.29,19.98,20.83,19.63,19.18,' \
                           '19.76,20.49,20.74,19.87,19.92,19.80,19.26,20.46,19.71,19.93,19.47,19.39,19.44,19.62,' \
                           '20.96,21.69,21.14,26.39,24.74,25.16,26.20,26.75,26.74,26.76,26.91,26.09,27.12,26.79,' \
                           '26.20,27.24,26.20,25.89,26.26,26.94,26.94,24.92,25.96,26.77,26.72,25.36,25.26,26.54,' \
                           '26.45,26.14,26.58,23.69,26.38,26.71,26.82,20.41,21.05,21.07,22.82]}\r\n'

        self.test_temp = [
            20.27, 20.50, 19.27, 19.62, 20.07, 19.25, 20.29, 19.98, 20.83,
            19.63, 19.18, 19.76, 20.49, 20.74, 19.87, 19.92, 19.80, 19.26,
            20.46, 19.71, 19.93, 19.47, 19.39, 19.44, 19.62, 20.96, 21.69,
            21.14, 26.39, 24.74, 25.16, 26.20, 26.75, 26.74, 26.76, 26.91,
            26.09, 27.12, 26.79, 26.20, 27.24, 26.20, 25.89, 26.26, 26.94,
            26.94, 24.92, 25.96, 26.77, 26.72, 25.36, 25.26, 26.54, 26.45,
            26.14, 26.58, 23.69, 26.38, 26.71, 26.82, 20.41, 21.05, 21.07,
            22.82
        ]
        self.test_ambient_temp = 22.51

        self.test_temp_str2 = '{"Ta":30.73, "To":[30.81,23.60,23.04,21.81,22.49,22.51,22.02,22.48,21.56,21.65,' \
                            '21.65,21.51,22.08,22.18,22.14,21.58,22.54,22.21,22.23,22.54,21.77,21.88,21.86,' \
                            '22.58,21.03,21.55,21.21,21.78,21.08,21.57,21.57,21.44,21.46,22.63,21.94,22.61,' \
                            '21.48,21.93,21.93,22.22,21.46,21.92,21.91,21.02,21.44,21.90,21.15,21.39,20.55,' \
                            '21.88,21.86,22.18,21.75,20.71,21.07,20.87,21.70,20.96,20.17,21.31,21.62,19.94,' \
                            '20.43,20.69]}\r\n'

        self.test_ambient_temp2 = 30.73

        #Use posix.openpty to create dummy Serial Port for Testing
        #http://stackoverflow.com/questions/2174071/how-to-use-dev-ptmx-for-create-a-virtual-serial-port
        self.fd_master, self.fd_slave = posix.openpty()
        self.test_sensor_config = MLX90620SensorProperties(
            arg_name='TestNode',
            arg_port=os.ttyname(self.fd_slave),
            arg_time_between_ambient_temp=0.2)
        #print self.test_sensor_config.__dict__
        self.test_sensor = MLX90620(self.test_sensor_config)
 def create_port(self):
     self.fdMaster, self.fdSlave = posix.openpty()
     self.ttyName = os.ttyname(self.fdSlave)
     return self.ttyName
 def create_port(self):
     self.fdMaster, self.fdSlave = posix.openpty()
     self.ttyName = os.ttyname(self.fdSlave)
     return self.ttyName