Skip to content

Commit b0ee18f

Browse files
committed
Add test cases for version injection
1 parent 201649b commit b0ee18f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pymongosql/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pymongo.driver_info import DriverInfo
1212
from pymongo.errors import ConnectionFailure
1313

14+
from . import __version__
1415
from .common import BaseCursor
1516
from .cursor import Cursor
1617
from .error import DatabaseError, OperationalError
@@ -20,7 +21,7 @@
2021
try:
2122
_VERSION = _get_version("pymongosql")
2223
except Exception:
23-
_VERSION = None
24+
_VERSION = __version__
2425

2526
_DRIVER_INFO = DriverInfo(name="PyMongoSQL", version=_VERSION)
2627

tests/test_connection.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import pytest
33

4-
from pymongosql.connection import Connection
4+
from pymongosql.connection import _VERSION, Connection
55
from pymongosql.cursor import Cursor
66
from pymongosql.error import OperationalError
77
from tests.conftest import TEST_DB, TEST_URI
@@ -26,6 +26,12 @@ def test_connection_init_with_basic_params(self, conn):
2626
assert conn.port == 27017
2727
assert conn.database_name == "test_db"
2828
assert conn.is_connected
29+
30+
# Verify driver name and version are correctly configured
31+
assert _VERSION is not None
32+
assert conn._pymongo_params.get("driver").name == "PyMongoSQL"
33+
assert conn._pymongo_params.get("driver").version == _VERSION
34+
2935
conn.close()
3036

3137
def test_connection_with_connect_false(self):

0 commit comments

Comments
 (0)