platiumky / pymssql

Automatically exported from code.google.com/p/pymssql
GNU Lesser General Public License v2.1
0 stars 0 forks source link

A few tests fail if running on a system that has SQL Server available on port 1433 #116

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I happen to be running the pymssql tests on a machine that has a port forward 
set up that forwards localhost:1433 to a SQL Server running in a virtual 
machine (thus in my tests/tests.cfg I connect to localhost:1433).

With this configuration, there are 4 test failures.

tests.test_config.TestConfig.test_tds_protocal_version_42 ... ERROR tests.test_config.TestConfig.test_tds_protocal_version_70 ... ERROR tests.test_config.TestConfig.test_tds_protocal_version_71 ... ERROR tests.test_config.TestConfig.test_tds_protocal_version_80 ... ERROR


Here's a traceback for one of them; the rest are similar:

ERROR: tests.test_config.TestConfig.test_tds_protocal_version_42

Traceback (most recent call last): File "/Users/marca/dev/git-repos/pymssql/.tox/py27/lib/python2.7/site-packages/nose/case.py", line 197, in runTest self.test(_self.arg) File "/Users/marca/dev/git-repos/pymssql/tests/test_config.py", line 58, in test_tds_protocal_version_42 tds_version='4.2' File "/Users/marca/dev/git-repos/pymssql/tests/test_config.py", line 20, in connect _mssql.connect(kwargs) File "_mssql.pyx", line 1628, in _mssql.connect (_mssql.c:16556) return MSSQLConnection(_args, **kwargs) File "_mssql.pyx", line 499, in _mssql.MSSQLConnection.init__ (_mssql.c:4697) maybe_raise_MSSQLDatabaseException(None) File "_mssql.pyx", line 1368, in _mssql.maybe_raise_MSSQLDatabaseException (_mssql.c:13063) raise ex MSSQLDatabaseException: (18456, "Login failed for user 'sa'.DB-Lib error message 18456, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed\n")


These are caused by the fact that the tests attempt don't specify a hostname so 
they try to connect to localhost and normally localhost doesn't have a SQL 
Server on port 1433 and this fails with a "Database connection failed" 
exception that gets caught by the test code. If there is a SQL Server actually 
responding on port 1433 though, then it tries to connect and raises a different 
exception because the "sa" user doesn't exit and this exception is not caught 
by the test code.

This is easy to fix by either widening the exceptions that are caught or by 
specifying a hostname that is likely not to exist. I'm leaning towards the 
latter.

Original issue reported on code.google.com by msabr...@gmail.com on 27 Feb 2013 at 6:16

GoogleCodeExporter commented 8 years ago
Fixed with 
http://code.google.com/p/pymssql/source/detail?r=0fc4086447fe3dcdb88f028889ef191
d8e9278be

Original comment by msabr...@gmail.com on 27 Feb 2013 at 6:28