Completed
Push — main ( 25807a...2ed45a )
by Jochen
01:37
created

tests.http.conftest.make_server()   A

Complexity

Conditions 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nop 0
dl 0
loc 14
rs 9.95
c 0
b 0
f 0
1
"""
2
:Copyright: 2007-2020 Jochen Kupperschmidt
3
:License: MIT, see LICENSE for details.
4
"""
5
6
from threading import Thread
7
8
import pytest
9
10
from weitersager.config import HttpConfig
11
from weitersager.http import ReceiveServer
12
13
14
@pytest.fixture
15
def make_server():
16
    # Per default, bind to localhost on random user port.
17
    def _wrapper(host='', port=0, *, api_tokens=None):
18
        config = HttpConfig(host, port, api_tokens=api_tokens)
19
20
        server = ReceiveServer(config)
21
22
        thread = Thread(target=server.handle_request)
23
        thread.start()
24
25
        return server
26
27
    return _wrapper
28
29
30
@pytest.fixture
31
def server(make_server):
32
    return make_server()
33