1111from urllib .request import urlopen
1212from uuid import uuid4
1313
14- from pytest import fixture
14+ from pytest import fixture , TempPathFactory
1515
1616HERE = Path (__file__ ).parent
1717RESOURCES = HERE / "resources"
1818
1919
20- @fixture
20+ @fixture ( scope = "session" )
2121def a_token () -> str :
2222 """Get a random UUID to use for a token."""
2323 return str (uuid4 ())
2424
2525
26- @fixture
26+ @fixture ( scope = "session" )
2727def an_unused_port () -> int :
2828 """Get a random unused port."""
2929 s = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
@@ -34,20 +34,23 @@ def an_unused_port() -> int:
3434 return port
3535
3636
37- @fixture (params = ["notebook" , "lab" ])
37+ @fixture (params = ["notebook" , "lab" ], scope = "session" )
3838def a_server_cmd (request : Any ) -> str :
3939 """Get a viable name for a command."""
4040 return request .param
4141
4242
43- @fixture
43+ @fixture ( scope = "session" )
4444def a_server (
4545 a_server_cmd : str ,
46- tmp_path : Path ,
46+ tmp_path_factory : TempPathFactory ,
4747 an_unused_port : int ,
4848 a_token : str ,
4949) -> Generator [str , None , None ]:
5050 """Get a running server."""
51+
52+ tmp_path = tmp_path_factory .mktemp (a_server_cmd )
53+
5154 # get a copy of the resources
5255 tests = tmp_path / "tests"
5356 tests .mkdir ()
0 commit comments