From b98a1df962601fda52175f58b3e432ec744da0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Thu, 5 Sep 2019 13:52:08 +0200 Subject: [PATCH] Ensure test pipes are deleted after each test session --- pipe_io_server/test_pipe_io_server.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pipe_io_server/test_pipe_io_server.py b/pipe_io_server/test_pipe_io_server.py index 2132474..651cba9 100644 --- a/pipe_io_server/test_pipe_io_server.py +++ b/pipe_io_server/test_pipe_io_server.py @@ -29,6 +29,12 @@ def get_test_init_params(): return join(here, 'in_pipe_tests'), join(here, 'out_pipe_tests') +def teardown_module(): + for pipe in get_test_init_params(): + if exists(pipe): + remove(pipe) + + def raise_if_thread_blocks(*, target, unblock_function): thread = Thread(target=target) thread.start() @@ -213,10 +219,8 @@ def test_json_io(io_pipes): def test_assign_message_handler(): pipe_io = PipeIOServer(*get_test_init_params()) pipe_io.handle_message = lambda msg: pipe_io.send_message(msg * 2) - pipe_io.start() - with IOPipes(pipe_io.in_pipe, pipe_io.out_pipe) as io_pipes: + with pipe_io, IOPipes(pipe_io.in_pipe, pipe_io.out_pipe) as io_pipes: for _ in range(100): test_data = token_urlsafe(32).encode() io_pipes.send_message(test_data) assert io_pipes.recv() == test_data * 2 - pipe_io.stop()