Esempio n. 1
0
 def test_close_before_open(self):
     pipe = NamedPipeWindows()
     handle = windll.kernel32.CreateFileW(str(pipe.path), GENERIC_READ, 0, None, OPEN_EXISTING, 0, None)
     self.assertNotEqual(handle, NamedPipeWindows.INVALID_HANDLE_VALUE)
     windll.kernel32.CloseHandle(handle)
     pipe.close()
     handle = windll.kernel32.CreateFileW(str(pipe.path), GENERIC_READ, 0, None, OPEN_EXISTING, 0, None)
     self.assertEqual(handle, NamedPipeWindows.INVALID_HANDLE_VALUE)
     # closing twice doesn't raise
     pipe.close()
Esempio n. 2
0
 def test_named_pipe(self):
     pipe = NamedPipeWindows()
     reader = ReadNamedPipeThreadWindows(pipe)
     reader.start()
     pipe.open()
     self.assertEqual(pipe.write(b"foo"), 3)
     self.assertEqual(pipe.write(b"bar"), 3)
     self.assertEqual(pipe.write(b"\0"), 1)
     reader.done.wait(4000)
     self.assertEqual(reader.error, None)
     self.assertEqual(reader.data, b"foobar")
     self.assertFalse(reader.is_alive())
     pipe.close()