|
21 | 21 | - test_context_manager_connection_closes: Test that context manager closes the connection. |
22 | 22 | """ |
23 | 23 |
|
24 | | -from mssql_python.exceptions import InterfaceError, ProgrammingError |
| 24 | +from mssql_python.exceptions import InterfaceError, ProgrammingError, DatabaseError |
25 | 25 | import mssql_python |
| 26 | +import sys |
26 | 27 | import pytest |
27 | 28 | import time |
28 | 29 | from mssql_python import connect, Connection, pooling, SQL_CHAR, SQL_WCHAR |
@@ -6380,8 +6381,8 @@ def test_set_attr_edge_cases(db_connection): |
6380 | 6381 |
|
6381 | 6382 | def test_set_attr_txn_isolation_effect(db_connection): |
6382 | 6383 | """Test that setting transaction isolation level actually affects transactions.""" |
6383 | | - from mssql_python.exceptions import DatabaseError |
6384 | | - conn_str = "Server=tcp:DESKTOP-1A982SC,1433;Database=master;TrustServerCertificate=yes;Trusted_Connection=yes;" |
| 6384 | + import os |
| 6385 | + conn_str = os.getenv('DB_CONNECTION_STRING') |
6385 | 6386 |
|
6386 | 6387 | # Create a temporary table for the test |
6387 | 6388 | cursor = db_connection.cursor() |
@@ -6463,8 +6464,6 @@ def test_set_attr_txn_isolation_effect(db_connection): |
6463 | 6464 |
|
6464 | 6465 | def test_set_attr_connection_timeout_effect(db_connection): |
6465 | 6466 | """Test that setting connection timeout actually affects query timeout.""" |
6466 | | - import time |
6467 | | - from mssql_python.exceptions import OperationalError |
6468 | 6467 |
|
6469 | 6468 | cursor = db_connection.cursor() |
6470 | 6469 | try: |
@@ -6505,8 +6504,6 @@ def test_set_attr_connection_timeout_effect(db_connection): |
6505 | 6504 |
|
6506 | 6505 | def test_set_attr_login_timeout_effect(conn_str): |
6507 | 6506 | """Test that setting login timeout affects connection time to invalid server.""" |
6508 | | - import time |
6509 | | - from mssql_python.exceptions import OperationalError |
6510 | 6507 |
|
6511 | 6508 | # Testing with a non-existent server to trigger a timeout |
6512 | 6509 | conn_parts = conn_str.split(';') |
@@ -6544,7 +6541,6 @@ def test_set_attr_login_timeout_effect(conn_str): |
6544 | 6541 |
|
6545 | 6542 | def test_set_attr_packet_size_effect(conn_str): |
6546 | 6543 | """Test that setting packet size affects network packet size.""" |
6547 | | - import sys |
6548 | 6544 |
|
6549 | 6545 | # Some drivers don't support changing packet size after connection |
6550 | 6546 | # Try with explicit packet size in connection string for the first size |
@@ -6771,7 +6767,7 @@ def test_attrs_before_connection_types(conn_str): |
6771 | 6767 | cursor = conn.cursor() |
6772 | 6768 | cursor.execute("SELECT DB_NAME()") |
6773 | 6769 | result = cursor.fetchone()[0] |
6774 | | - assert result.lower() == "master" |
| 6770 | + assert result.lower() == "testdb" |
6775 | 6771 | conn.close() |
6776 | 6772 |
|
6777 | 6773 | def test_set_attr_unsupported_attribute(db_connection): |
|
0 commit comments