-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
55 lines (39 loc) · 1.43 KB
/
Copy pathconftest.py
File metadata and controls
55 lines (39 loc) · 1.43 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from datetime import datetime, timedelta
import pytest
from sqlbind_t import tfstring
tfstring.init(['tests.*'], pytest=True)
import sqlbind_t.dialect
from sqlbind_t.template import HAS_TSTRINGS
def pytest_collection_modifyitems(config, items):
if not HAS_TSTRINGS:
marker = pytest.mark.skip(reason='doctests require t-strings')
for it in items:
if it.__class__.__name__ == 'DoctestItem':
it.add_marker(marker)
class connection:
@staticmethod
def execute(sql, params):
return ['results...']
@pytest.fixture(autouse=True)
def set_doctest_ns(doctest_namespace):
doctest_namespace['render'] = sqlbind_t.dialect.render
doctest_namespace['connection'] = connection
doctest_namespace['cond'] = sqlbind_t.cond
doctest_namespace['not_none'] = sqlbind_t.not_none
doctest_namespace['required'] = sqlbind_t.required
doctest_namespace['E'] = sqlbind_t.E
doctest_namespace['datetime'] = datetime
doctest_namespace['timedelta'] = timedelta
doctest_namespace['AND_'] = sqlbind_t.AND_
doctest_namespace['WHERE'] = sqlbind_t.WHERE
doctest_namespace['sql'] = sqlbind_t.sql
doctest_namespace['text'] = sqlbind_t.text
@pytest.fixture(autouse=True)
def set_dprint():
calls = []
def dprint(*args, **kwargs):
calls.append((args, kwargs))
__builtins__['dprint'] = dprint
yield
for args, kwargs in calls:
print(*args, **kwargs)