diff --git a/tsstats/tests/test_client.py b/tsstats/tests/test_client.py index ec961db..3cdcc03 100644 --- a/tsstats/tests/test_client.py +++ b/tsstats/tests/test_client.py @@ -2,18 +2,23 @@ import pytest from tsstats.client import Client, Clients -clients = Clients() -cl1 = Client('1') -cl2 = Client('2') -clients += cl1 -clients += cl2 -uidcl1 = Client('UID1') -uidcl2 = Client('UID2') -clients += uidcl1 -clients += uidcl2 + +@pytest.fixture(scope='module') +def clients(): + clients = Clients() + cl1 = Client('1') + cl2 = Client('2') + clients += cl1 + clients += cl2 + uidcl1 = Client('UID1') + uidcl2 = Client('UID2') + clients += uidcl1 + clients += uidcl2 + return (clients, cl1, cl2, uidcl1, uidcl2) -def test_client_get(): +def test_client_get(clients): + clients, cl1, cl2, uidcl1, uidcl2 = clients assert clients['1'] == cl1 assert clients['2'] == cl2 assert clients['UID1'] == uidcl1 @@ -23,14 +28,16 @@ def test_client_get(): clients['UID3'] -def test_client_repr(): +def test_client_repr(clients): + clients, _, _, _, _ = clients assert str(clients['1']) == '<1,None>' assert str(clients['2']) == '<2,None>' assert str(clients['UID1']) == '' assert str(clients['UID2']) == '' -def test_clients_iter(): +def test_clients_iter(clients): + clients, cl1, cl2, uidcl1, uidcl2 = clients client_list = list(iter(clients)) assert cl1 in client_list assert cl2 in client_list @@ -38,6 +45,7 @@ def test_clients_iter(): assert uidcl2 in client_list -def test_clients_delete(): +def test_clients_delete(clients): + clients, cl1, _, _, _ = clients del clients['1'] assert cl1 not in clients diff --git a/tsstats/tests/test_ident_map.py b/tsstats/tests/test_ident_map.py index 09d6c1f..ce0c8c4 100644 --- a/tsstats/tests/test_ident_map.py +++ b/tsstats/tests/test_ident_map.py @@ -1,19 +1,25 @@ +import pytest + from tsstats.client import Client, Clients -ident_map = { - '1': '2', - '5': '2', - 'UID1': 'UID2', - 'UID5': 'UID2' -} -clients = Clients(ident_map) -cl = Client('2', 'Client2') -uidcl = Client('UID2', 'Client2++') -clients += cl -clients += uidcl + +@pytest.fixture(scope='module') +def identmap_clients(): + clients = Clients({ + '1': '2', + '5': '2', + 'UID1': 'UID2', + 'UID5': 'UID2' + }) + cl = Client('2', 'Client2') + uidcl = Client('UID2', 'Client2++') + clients += cl + clients += uidcl + return (clients, cl, uidcl) -def test_ident_map(): +def test_ident_map(identmap_clients): + clients, cl, uidcl = identmap_clients assert clients['1'] == cl assert clients['5'] == cl assert clients['UID1'] == uidcl