File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,9 +16,7 @@ pytest-scim2-server creates a ``scim2_server`` fixture that runs an instance of
1616import requests
1717
1818def test_scim_foobar (scim2_server ):
19- host, port = scim2_server
20-
21- res = request.get(f " http:// { host} : { port} " )
19+ res = request.get(f " http://localhost: { scim2_server.port} " )
2220 ...
2321```
2422
@@ -32,8 +30,7 @@ from scim2_client.engines.httpx import SyncSCIMClient
3230
3331@pytest.fixture (scope = " session" )
3432def scim_client (scim2_server ):
35- host, port = scim2_server
36- http_client = Client(base_url = f " http:// { host} : { port} " )
33+ http_client = Client(base_url = f " http://localhost: { scim2_server.port} " )
3734 scim_client = SyncSCIMClient(http_client)
3835 scim_client.discover()
3936 return scim_client
Original file line number Diff line number Diff line change 11import threading
22import wsgiref .simple_server
3+ from dataclasses import dataclass
34
45import portpicker
56import pytest
910from scim2_server .utils import load_default_schemas
1011
1112
13+ @dataclass
14+ class Server :
15+ """A proxy object that is returned by the pytest fixture."""
16+
17+ port : int
18+ """The port on which the local http server listens."""
19+
20+ app : SCIMProvider
21+ """The scim2-server WSGI application."""
22+
23+
1224@pytest .fixture (scope = "session" )
1325def scim2_server ():
1426 """SCIM2 server running in a thread."""
@@ -27,8 +39,11 @@ def scim2_server():
2739
2840 server_thread = threading .Thread (target = httpd .serve_forever )
2941 server_thread .start ()
42+
43+ server = Server (port = port , app = provider )
44+
3045 try :
31- yield host , port
46+ yield server
3247 finally :
3348 httpd .shutdown ()
3449 server_thread .join ()
Original file line number Diff line number Diff line change 55
66@pytest .fixture (scope = "session" )
77def scim_client (scim2_server ):
8- host , port = scim2_server
9- http_client = Client (base_url = f"http://{ host } :{ port } " )
8+ http_client = Client (base_url = f"http://localhost:{ scim2_server .port } " )
109 scim_client = SyncSCIMClient (http_client )
1110 scim_client .discover ()
1211 return scim_client
You can’t perform that action at this time.
0 commit comments