|
17 | 17 | import pytest |
18 | 18 |
|
19 | 19 | import snowflake.connector |
20 | | -from snowflake.connector import ( |
21 | | - DatabaseError, |
22 | | - OperationalError, |
23 | | - ProgrammingError, |
24 | | - SnowflakeConnection, |
25 | | - connect, |
26 | | -) |
| 20 | +from snowflake.connector import DatabaseError, OperationalError, ProgrammingError |
27 | 21 | from snowflake.connector.compat import IS_WINDOWS |
28 | 22 | from snowflake.connector.connection import DEFAULT_CLIENT_PREFETCH_THREADS |
29 | 23 | from snowflake.connector.description import CLIENT_NAME |
@@ -1563,92 +1557,6 @@ def test_no_new_warnings_or_errors_on_successful_basic_select(conn_cnx, caplog): |
1563 | 1557 | ) |
1564 | 1558 |
|
1565 | 1559 |
|
1566 | | -@pytest.mark.skipolddriver |
1567 | | -def test_connect_metadata_preservation(): |
1568 | | - """Test that the sync connect function preserves metadata from SnowflakeConnection.__init__. |
1569 | | -
|
1570 | | - This test verifies that various inspection methods return consistent metadata, |
1571 | | - ensuring IDE support, type checking, and documentation generation work correctly. |
1572 | | - """ |
1573 | | - import inspect |
1574 | | - |
1575 | | - # Test 1: Check __name__ is correct |
1576 | | - assert ( |
1577 | | - connect.__name__ == "__init__" |
1578 | | - ), f"connect.__name__ should be 'connect', but got '{connect.__name__}'" |
1579 | | - |
1580 | | - # Test 2: Check __wrapped__ points to SnowflakeConnection.__init__ |
1581 | | - assert hasattr(connect, "__wrapped__"), "connect should have __wrapped__ attribute" |
1582 | | - assert ( |
1583 | | - connect.__wrapped__ is SnowflakeConnection.__init__ |
1584 | | - ), "connect.__wrapped__ should reference SnowflakeConnection.__init__" |
1585 | | - |
1586 | | - # Test 3: Check __module__ is preserved |
1587 | | - assert hasattr(connect, "__module__"), "connect should have __module__ attribute" |
1588 | | - assert connect.__module__ == SnowflakeConnection.__init__.__module__, ( |
1589 | | - f"connect.__module__ should match SnowflakeConnection.__init__.__module__, " |
1590 | | - f"but got '{connect.__module__}' vs '{SnowflakeConnection.__init__.__module__}'" |
1591 | | - ) |
1592 | | - |
1593 | | - # Test 4: Check __doc__ is preserved |
1594 | | - assert hasattr(connect, "__doc__"), "connect should have __doc__ attribute" |
1595 | | - assert ( |
1596 | | - connect.__doc__ == SnowflakeConnection.__init__.__doc__ |
1597 | | - ), "connect.__doc__ should match SnowflakeConnection.__init__.__doc__" |
1598 | | - |
1599 | | - # Test 5: Check __annotations__ are preserved (or at least available) |
1600 | | - assert hasattr( |
1601 | | - connect, "__annotations__" |
1602 | | - ), "connect should have __annotations__ attribute" |
1603 | | - src_annotations = getattr(SnowflakeConnection.__init__, "__annotations__", {}) |
1604 | | - connect_annotations = getattr(connect, "__annotations__", {}) |
1605 | | - assert connect_annotations == src_annotations, ( |
1606 | | - f"connect.__annotations__ should match SnowflakeConnection.__init__.__annotations__, " |
1607 | | - f"but got {connect_annotations} vs {src_annotations}" |
1608 | | - ) |
1609 | | - |
1610 | | - # Test 6: Check inspect.signature works correctly |
1611 | | - try: |
1612 | | - connect_sig = inspect.signature(connect) |
1613 | | - source_sig = inspect.signature(SnowflakeConnection.__init__) |
1614 | | - assert str(connect_sig) == str(source_sig), ( |
1615 | | - f"inspect.signature(connect) should match inspect.signature(SnowflakeConnection.__init__), " |
1616 | | - f"but got '{connect_sig}' vs '{source_sig}'" |
1617 | | - ) |
1618 | | - except Exception as e: |
1619 | | - pytest.fail(f"inspect.signature(connect) failed: {e}") |
1620 | | - |
1621 | | - # Test 7: Check inspect.getdoc works correctly |
1622 | | - connect_doc = inspect.getdoc(connect) |
1623 | | - source_doc = inspect.getdoc(SnowflakeConnection.__init__) |
1624 | | - assert ( |
1625 | | - connect_doc == source_doc |
1626 | | - ), "inspect.getdoc(connect) should match inspect.getdoc(SnowflakeConnection.__init__)" |
1627 | | - |
1628 | | - # Test 8: Check that connect is callable |
1629 | | - assert callable(connect), "connect should be callable" |
1630 | | - |
1631 | | - # Test 9: Check type() and __class__ values (important for user introspection) |
1632 | | - assert ( |
1633 | | - type(connect).__name__ == "function" |
1634 | | - ), f"type(connect).__name__ should be 'function', but got '{type(connect).__name__}'" |
1635 | | - assert ( |
1636 | | - connect.__class__.__name__ == "function" |
1637 | | - ), f"connect.__class__.__name__ should be 'function', but got '{connect.__class__.__name__}'" |
1638 | | - assert inspect.isfunction( |
1639 | | - connect |
1640 | | - ), "connect should be recognized as a function by inspect.isfunction()" |
1641 | | - |
1642 | | - # Test 10: Verify the function has proper introspection capabilities |
1643 | | - # IDEs and type checkers should be able to resolve parameters |
1644 | | - sig = inspect.signature(connect) |
1645 | | - params = list(sig.parameters.keys()) |
1646 | | - assert ( |
1647 | | - len(params) > 0 |
1648 | | - ), "connect should have parameters from SnowflakeConnection.__init__" |
1649 | | - # Should have parameters like account, user, password, etc. |
1650 | | - |
1651 | | - |
1652 | 1560 | @pytest.mark.skipolddriver |
1653 | 1561 | def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_mismatch_ocsp_enabled( |
1654 | 1562 | conn_cnx, is_public_test, is_local_dev_setup, caplog |
|
0 commit comments