File tree Expand file tree Collapse file tree 3 files changed +19
-8
lines changed Expand file tree Collapse file tree 3 files changed +19
-8
lines changed 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
16
16
import requests
17
17
18
18
def 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} " )
22
20
...
23
21
```
24
22
@@ -32,8 +30,7 @@ from scim2_client.engines.httpx import SyncSCIMClient
32
30
33
31
@pytest.fixture (scope = " session" )
34
32
def 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} " )
37
34
scim_client = SyncSCIMClient(http_client)
38
35
scim_client.discover()
39
36
return scim_client
Original file line number Diff line number Diff line change 1
1
import threading
2
2
import wsgiref .simple_server
3
+ from dataclasses import dataclass
3
4
4
5
import portpicker
5
6
import pytest
9
10
from scim2_server .utils import load_default_schemas
10
11
11
12
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
+
12
24
@pytest .fixture (scope = "session" )
13
25
def scim2_server ():
14
26
"""SCIM2 server running in a thread."""
@@ -27,8 +39,11 @@ def scim2_server():
27
39
28
40
server_thread = threading .Thread (target = httpd .serve_forever )
29
41
server_thread .start ()
42
+
43
+ server = Server (port = port , app = provider )
44
+
30
45
try :
31
- yield host , port
46
+ yield server
32
47
finally :
33
48
httpd .shutdown ()
34
49
server_thread .join ()
Original file line number Diff line number Diff line change 5
5
6
6
@pytest .fixture (scope = "session" )
7
7
def 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 } " )
10
9
scim_client = SyncSCIMClient (http_client )
11
10
scim_client .discover ()
12
11
return scim_client
You can’t perform that action at this time.
0 commit comments