BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
microscope.testsuite.test_devices.TestSerialMock Class Reference
Inheritance diagram for microscope.testsuite.test_devices.TestSerialMock:

Classes

class  Serial
 

Public Member Functions

def setUp (self)
 
def test_simple_commands (self)
 
def test_partial_commands (self)
 
def test_multiple_commands (self)
 
def test_unix_eol (self)
 
def test_write (self)
 

Public Attributes

 serial
 
 mock
 

Detailed Description

Definition at line 48 of file test_devices.py.

Member Function Documentation

◆ setUp()

def microscope.testsuite.test_devices.TestSerialMock.setUp (   self)

Definition at line 62 of file test_devices.py.

62 def setUp(self):
63 self.serial = TestSerialMock.Serial()
64 patcher = unittest.mock.patch.object(
65 TestSerialMock.Serial, "handle", wraps=self.serial.handle
66 )
67 self.addCleanup(patcher.stop)
68 self.mock = patcher.start()
69

◆ test_multiple_commands()

def microscope.testsuite.test_devices.TestSerialMock.test_multiple_commands (   self)

Definition at line 80 of file test_devices.py.

80 def test_multiple_commands(self):
81 self.serial.write(b"foo\r\nbar\r\n")
82 calls = [unittest.mock.call(x) for x in [b"foo", b"bar"]]
83 self.assertEqual(self.serial.handle.mock_calls, calls)
84

◆ test_partial_commands()

def microscope.testsuite.test_devices.TestSerialMock.test_partial_commands (   self)

Definition at line 74 of file test_devices.py.

74 def test_partial_commands(self):
75 self.serial.write(b"fo")
76 self.serial.write(b"o")
77 self.serial.write(b"\r\n")
78 self.serial.handle.assert_called_once_with(b"foo")
79

◆ test_simple_commands()

def microscope.testsuite.test_devices.TestSerialMock.test_simple_commands (   self)

Definition at line 70 of file test_devices.py.

70 def test_simple_commands(self):
71 self.serial.write(b"foo\r\n")
72 self.mock.assert_called_once_with(b"foo")
73

◆ test_unix_eol()

def microscope.testsuite.test_devices.TestSerialMock.test_unix_eol (   self)

Definition at line 85 of file test_devices.py.

85 def test_unix_eol(self):
86 self.serial.eol = b"\n"
87 self.serial.write(b"foo\nbar\n")
88 calls = [unittest.mock.call(x) for x in [b"foo", b"bar"]]
89 self.assertEqual(self.serial.handle.mock_calls, calls)
90

◆ test_write()

def microscope.testsuite.test_devices.TestSerialMock.test_write (   self)

Definition at line 91 of file test_devices.py.

91 def test_write(self):
92 self.serial.write(b"echo qux\r\n")
93 self.assertEqual(self.serial.readline(), b"qux\r\n")
94
95

Member Data Documentation

◆ mock

microscope.testsuite.test_devices.TestSerialMock.mock

Definition at line 68 of file test_devices.py.

◆ serial

microscope.testsuite.test_devices.TestSerialMock.serial

Definition at line 63 of file test_devices.py.


The documentation for this class was generated from the following file: