summaryrefslogtreecommitdiff
path: root/tests/testutils/file_server.py
blob: 05f896013c2da0297d99cc07425eaf94a0d8d148 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from contextlib import contextmanager

from .ftp_server import SimpleFtpServer
from .http_server import SimpleHttpServer


@contextmanager
def create_file_server(file_server_type):
    if file_server_type == 'FTP':
        server = SimpleFtpServer()
    elif file_server_type == 'HTTP':
        server = SimpleHttpServer()
    else:
        assert False

    try:
        yield server
    finally:
        server.stop()