@@ -1133,49 +1133,26 @@ class TestConfigC(PydanticModel):
11331133
11341134def test_mssql_engine_import_validator ():
11351135 """Test that MSSQL import validator respects driver configuration."""
1136- with pytest .raises (
1137- ConfigError ,
1138- match = re .escape (
1139- "Failed to import the 'pyodbc' library for MSSQL connections. This may be due to a missing "
1140- "or incompatible installation. Please ensure the required dependency is installed by "
1141- 'running: `pip install "sqlmesh[mssql-odbc]"`. For more details, check the logs '
1142- "in the 'logs/' folder, or rerun the command with the '--debug' flag."
1143- ),
1144- ):
1145- # Test PyODBC driver suggests mssql-odbc extra
1136+
1137+ # Test PyODBC driver suggests mssql-odbc extra when import fails
1138+ with pytest .raises (ConfigError , match = r"pip install \"sqlmesh\[mssql-odbc\]\"" ):
11461139 with patch ("importlib.import_module" ) as mock_import :
11471140 mock_import .side_effect = ImportError ("No module named 'pyodbc'" )
11481141 MSSQLConnectionConfig (host = "localhost" , driver = "pyodbc" )
11491142
1150- with pytest .raises (
1151- ConfigError ,
1152- match = re .escape (
1153- "Failed to import the 'pymssql' library for MSSQL connections. This may be due to a missing "
1154- "or incompatible installation. Please ensure the required dependency is installed by "
1155- 'running: `pip install "sqlmesh[mssql]"`. For more details, check the logs '
1156- "in the 'logs/' folder, or rerun the command with the '--debug' flag."
1157- ),
1158- ):
1159- # Test PyMSSQL driver suggests mssql extra
1143+ # Test PyMSSQL driver suggests mssql extra when import fails
1144+ with pytest .raises (ConfigError , match = r"pip install \"sqlmesh\[mssql\]\"" ):
11601145 with patch ("importlib.import_module" ) as mock_import :
11611146 mock_import .side_effect = ImportError ("No module named 'pymssql'" )
11621147 MSSQLConnectionConfig (host = "localhost" , driver = "pymssql" )
11631148
1164- with pytest .raises (
1165- ConfigError ,
1166- match = re .escape (
1167- "Failed to import the 'pymssql' library for MSSQL connections. This may be due to a missing "
1168- "or incompatible installation. Please ensure the required dependency is installed by "
1169- 'running: `pip install "sqlmesh[mssql]"`. For more details, check the logs '
1170- "in the 'logs/' folder, or rerun the command with the '--debug' flag."
1171- ),
1172- ):
1173- # Test default driver (pymssql) suggests mssql extra
1149+ # Test default driver (pymssql) suggests mssql extra when import fails
1150+ with pytest .raises (ConfigError , match = r"pip install \"sqlmesh\[mssql\]\"" ):
11741151 with patch ("importlib.import_module" ) as mock_import :
11751152 mock_import .side_effect = ImportError ("No module named 'pymssql'" )
11761153 MSSQLConnectionConfig (host = "localhost" ) # No driver specified
11771154
1178- # Test successful import doesn't raise exception
1155+ # Test successful import works without error
11791156 with patch ("importlib.import_module" ) as mock_import :
11801157 mock_import .return_value = None
11811158 config = MSSQLConnectionConfig (host = "localhost" , driver = "pyodbc" )
0 commit comments