/tests/net/test_pipe.py
Python | 47 lines | 31 code | 15 blank | 1 comment | 1 complexity | 1b74567e4cf3476de3e604ae8c2e759b MD5 | raw file
1#!/usr/bin/env python 2 3import pytest 4if pytest.PLATFORM == "win32": 5 pytest.skip("Unsupported Platform") 6 7from circuits import Manager 8from circuits.net.sockets import Pipe 9from circuits.core.pollers import Select 10from circuits.net.events import close, write 11 12from .client import Client 13 14 15def pytest_generate_tests(metafunc): 16 metafunc.addcall(funcargs={"Poller": Select}) 17 18 19def test_pipe(Poller): 20 m = Manager() + Poller() 21 22 a, b = Pipe("a", "b") 23 a.register(m) 24 b.register(m) 25 26 a = Client(channel=a.channel).register(m) 27 b = Client(channel=b.channel).register(m) 28 29 m.start() 30 31 try: 32 assert pytest.wait_for(a, "ready") 33 assert pytest.wait_for(b, "ready") 34 35 a.fire(write(b"foo")) 36 assert pytest.wait_for(b, "data", b"foo") 37 38 b.fire(write(b"foo")) 39 assert pytest.wait_for(a, "data", b"foo") 40 41 a.fire(close()) 42 assert pytest.wait_for(a, "disconnected") 43 44 b.fire(close()) 45 assert pytest.wait_for(b, "disconnected") 46 finally: 47 m.stop()