Skip to content

Commit 68e07a2

Browse files
committed
Simplify tests
1 parent d860948 commit 68e07a2

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

tests/test_server.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,15 @@ def test_shutdown_gracefully(client_session):
4242

4343

4444
class TestServerThreaded():
45-
def test_run_forever(self):
46-
server = WebsocketServer(port=0)
47-
assert server.thread == None
48-
49-
# Run threaded
50-
server.run_forever(threaded=True)
51-
assert server.thread
52-
assert not isinstance(server.thread, threading._MainThread)
53-
assert server.thread.is_alive()
54-
55-
def test_shutdown(self):
56-
server = WebsocketServer(port=0)
57-
server.run_forever(threaded=True)
58-
assert server.thread.is_alive()
59-
60-
# Shutdown de-facto way
61-
server.shutdown()
62-
assert not server.thread.is_alive()
45+
def test_run_forever(self, threaded_server):
46+
assert threaded_server.thread
47+
assert not isinstance(threaded_server.thread, threading._MainThread)
48+
assert threaded_server.thread.is_alive()
49+
50+
def test_shutdown(self, threaded_server):
51+
assert threaded_server.thread.is_alive()
52+
threaded_server.shutdown()
53+
assert not threaded_server.thread.is_alive()
6354

6455

6556
def test_shutdown_abruptly(client_session):

0 commit comments

Comments
 (0)