File: test_backend_finding.py

package info (click to toggle)
python-socketpool 0.5.3-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: python: 629; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 807 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pytest
from socketpool.pool import ConnectionPool
from socketpool.conn import TcpConnector

def make_and_check_backend(expected_name, **kw):
    pool = ConnectionPool(TcpConnector, **kw)
    assert pool.backend == expected_name
    return pool


def test_default_backend():
    make_and_check_backend('thread')


def test_thread_backend():
    make_and_check_backend('thread', backend='thread')


def test_gevent_backend():
    pytest.importorskip('gevent')
    make_and_check_backend('gevent', backend='gevent')


def test_eventlet_backend():
    pytest.importorskip('eventlet')
    make_and_check_backend('eventlet', backend='eventlet')


def test_thread_backend_as_module():
    from socketpool import backend_thread
    make_and_check_backend('socketpool.backend_thread', backend=backend_thread)