14
14
from .dev_server_test_helper import MyFakeSite , SERVER_ADDRESS , find_unused_port , LOGGER , OUTPUT_FOLDER
15
15
16
16
17
- def test_server_on_used_port (site_and_base_path : Tuple [MyFakeSite , str ]):
17
+ def test_server_on_used_port (site_and_base_path : Tuple [MyFakeSite , str ]) -> None :
18
+ """Check error if port for nikola serve is already being used.
19
+
20
+ `nikola serve` uses a default port and if that port is already in use it should print out a nice
21
+ error message that tells the user what happend and how to fix this.
22
+
23
+ To test the case where the port is already in use, we open a socket on the same port that we use
24
+ for `nikola serve` before starting the server.
25
+
26
+ The program should exit with a return code of 3 in this case and print out a message to the user.
27
+ """
28
+
18
29
site , base_path = site_and_base_path
30
+ site .show_tracebacks = False
19
31
command_serve = serve .CommandServe ()
20
32
command_serve .set_site (site )
21
33
command_serve .serve_pidfile = "there is no file with this name we hope"
@@ -42,7 +54,8 @@ def test_server_on_used_port(site_and_base_path: Tuple[MyFakeSite, str]):
42
54
result = future_to_run_web_server .result ()
43
55
assert 3 == result
44
56
45
-
57
+ # TODO: check if this works on windows
58
+ # for now we skip this assert on windows platforms.
46
59
if not sys .platform == 'win32' :
47
60
assert re .match (
48
61
r"Port address \d+ already in use, "
0 commit comments