-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconftest.py
More file actions
31 lines (23 loc) · 726 Bytes
/
conftest.py
File metadata and controls
31 lines (23 loc) · 726 Bytes
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
"""For testing."""
import sys
import pytest
from twisted.python import log
from pywwa import CTX, CTX_DEFAULTS
from pywwa.database import get_dbconnc
# Dragons
# pytest + twisted + click == too much magic for poor me
# So, this effectively disables reactor.stop() from working
CTX_DEFAULTS["shutdown_delay"] = 1800
log.startLogging(sys.stdout)
@pytest.fixture(autouse=True)
def setup_and_teardown():
"""Something to fix the hacky global namespace mucking I do."""
CTX.update(CTX_DEFAULTS)
yield
CTX.update(CTX_DEFAULTS)
@pytest.fixture(scope="function")
def cursor(database):
"""Return a disposable database cursor."""
pgconn, cursor = get_dbconnc(database)
yield cursor
pgconn.close()