Skip to content

Commit 540cc73

Browse files
committed
Use pytest instead of unittest
1 parent 6e0a4d0 commit 540cc73

14 files changed

+3312
-3185
lines changed

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
license='MIT License',
6262
packages=['dbutils'],
6363
extras_require={
64-
"pg": ["PyGreSQL >= 5"]
65-
}
64+
"pg": ["PyGreSQL>=5"]
65+
},
66+
tests_require=["pytest>=7", "ruff"]
6667
)

tests/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# DBUtils tests
1+
"""DBUtils tests"""
2+
3+
# make sure the mock pg module is installed
4+
from . import mock_pg as pg # noqa: F401

tests/mock_db.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
"""This module serves as a mock object for the DB-API 2 module"""
22

3+
import sys
4+
5+
import pytest
6+
7+
__all__ = ['dbapi']
8+
9+
310
threadsafety = 2
411

512

13+
@pytest.fixture()
14+
def dbapi():
15+
"""Get mock DB API 2 module."""
16+
mock_db = sys.modules[__name__]
17+
mock_db.threadsafety = 2
18+
return mock_db
19+
20+
621
class Error(Exception):
722
pass
823

tests/mock_pg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import sys
44

5+
56
sys.modules['pg'] = sys.modules[__name__]
67

78

0 commit comments

Comments
 (0)