|
24 | 24 |
|
25 | 25 | import snowflake.connector.aio |
26 | 26 | from snowflake.connector import DatabaseError, OperationalError, ProgrammingError |
27 | | -from snowflake.connector.aio import SnowflakeConnection, connect |
| 27 | +from snowflake.connector.aio import SnowflakeConnection |
28 | 28 | from snowflake.connector.aio._description import CLIENT_NAME |
29 | 29 | from snowflake.connector.compat import IS_WINDOWS |
30 | 30 | from snowflake.connector.connection import DEFAULT_CLIENT_PREFETCH_THREADS |
@@ -1751,80 +1751,3 @@ async def test_no_new_warnings_or_errors_on_successful_basic_select(conn_cnx, ca |
1751 | 1751 | f"Error count increased from {baseline_error_count} to {test_error_count}. " |
1752 | 1752 | f"New errors: {[r.getMessage() for r in caplog.records if r.levelno >= logging.ERROR]}" |
1753 | 1753 | ) |
1754 | | - |
1755 | | - |
1756 | | -@pytest.mark.skipolddriver |
1757 | | -async def test_connect_metadata_preservation(): |
1758 | | - """Test that the async connect function preserves metadata from SnowflakeConnection.__init__. |
1759 | | -
|
1760 | | - This test verifies that various inspection methods return consistent metadata, |
1761 | | - ensuring IDE support, type checking, and documentation generation work correctly. |
1762 | | - """ |
1763 | | - import inspect |
1764 | | - |
1765 | | - # Test 1: Check __name__ and __qualname__ are overridden correctly |
1766 | | - # tODO: the only difference is that this is __init__ in synch connect |
1767 | | - assert ( |
1768 | | - connect.__name__ == "connect" |
1769 | | - ), f"connect.__name__ should be 'connect', but got '{connect.__name__}'" |
1770 | | - assert ( |
1771 | | - connect.__qualname__ == "connect" |
1772 | | - ), f"connect.__qualname__ should be 'connect', but got '{connect.__qualname__}'" |
1773 | | - |
1774 | | - # Test 2: Check __wrapped__ points to SnowflakeConnection.__init__ |
1775 | | - assert hasattr(connect, "__wrapped__"), "connect should have __wrapped__ attribute" |
1776 | | - assert ( |
1777 | | - connect.__wrapped__ is SnowflakeConnection.__init__ |
1778 | | - ), "connect.__wrapped__ should reference SnowflakeConnection.__init__" |
1779 | | - |
1780 | | - # Test 3: Check __module__ is preserved |
1781 | | - assert hasattr(connect, "__module__"), "connect should have __module__ attribute" |
1782 | | - assert connect.__module__ == SnowflakeConnection.__init__.__module__, ( |
1783 | | - f"connect.__module__ should match SnowflakeConnection.__init__.__module__, " |
1784 | | - f"but got '{connect.__module__}' vs '{SnowflakeConnection.__init__.__module__}'" |
1785 | | - ) |
1786 | | - |
1787 | | - # Test 4: Check __doc__ is preserved |
1788 | | - assert hasattr(connect, "__doc__"), "connect should have __doc__ attribute" |
1789 | | - assert ( |
1790 | | - connect.__doc__ == SnowflakeConnection.__init__.__doc__ |
1791 | | - ), "connect.__doc__ should match SnowflakeConnection.__init__.__doc__" |
1792 | | - |
1793 | | - # Test 5: Check __annotations__ are preserved (or at least available) |
1794 | | - assert hasattr( |
1795 | | - connect, "__annotations__" |
1796 | | - ), "connect should have __annotations__ attribute" |
1797 | | - src_annotations = getattr(SnowflakeConnection.__init__, "__annotations__", {}) |
1798 | | - connect_annotations = getattr(connect, "__annotations__", {}) |
1799 | | - assert connect_annotations == src_annotations, ( |
1800 | | - f"connect.__annotations__ should match SnowflakeConnection.__init__.__annotations__, " |
1801 | | - f"but got {connect_annotations} vs {src_annotations}" |
1802 | | - ) |
1803 | | - |
1804 | | - # Test 6: Check inspect.signature works correctly |
1805 | | - try: |
1806 | | - connect_sig = inspect.signature(connect) |
1807 | | - source_sig = inspect.signature(SnowflakeConnection.__init__) |
1808 | | - assert str(connect_sig) == str(source_sig), ( |
1809 | | - f"inspect.signature(connect) should match inspect.signature(SnowflakeConnection.__init__), " |
1810 | | - f"but got '{connect_sig}' vs '{source_sig}'" |
1811 | | - ) |
1812 | | - except Exception as e: |
1813 | | - pytest.fail(f"inspect.signature(connect) failed: {e}") |
1814 | | - |
1815 | | - # Test 7: Check inspect.getdoc works correctly |
1816 | | - connect_doc = inspect.getdoc(connect) |
1817 | | - source_doc = inspect.getdoc(SnowflakeConnection.__init__) |
1818 | | - assert connect_doc == source_doc, ( |
1819 | | - "inspect.getdoc(connect) should match inspect.getdoc(SnowflakeConnection.__init__)" |
1820 | | - ) |
1821 | | - |
1822 | | - # Test 8: Check that connect is callable and returns expected type |
1823 | | - assert callable(connect), "connect should be callable" |
1824 | | - |
1825 | | - # Test 9: Verify the instance has proper introspection capabilities |
1826 | | - # IDEs and type checkers should be able to resolve parameters |
1827 | | - sig = inspect.signature(connect) |
1828 | | - params = list(sig.parameters.keys()) |
1829 | | - assert len(params) > 0, "connect should have parameters from SnowflakeConnection.__init__" |
1830 | | - |
0 commit comments