D
dj
Hello,
I have just started working with minimock in doctest.
I want to create a mock pyodbc object which returns a string value
when the method execute is called.
Here is my doctest:
.... ServerName = 'test_server'
.... DbName = 'test_database'
.... User = 'test_user'
.... Pass ='test_pass'
.... connstring ='DRIVER{SQL Server};SERVER=%s;DATABASE=%s;UID=
%s;PWD=%s;' % (ServerName,
.... DbName, User, Pass)
.... cnx = pyodbc.connect(connstring)
.... cur = cnx.cursor()
.... name = cur.execute("select user_id from user")
.... print 'name:%s' % name
....
Here is the output from doctest:
*****************************************************************************
File ".\pyodbc_test.txt", line 35, in pyodbc_test.txt
Failed example:
database_response() #doctest: +ELLIPSIS
Expected nothing
Got:
Called pyodbc.connect({DRIVER{SQLServer};
SERVER=test_server;DATABASE=test_database;UID=test_user;PWD=test_pass;')
Called pyodbc.cursor()
Called pyodbc.execute('select user_id from users')
name: None
*******************************************************************************************
The last line of the output, name : Name, should read, name: Return
this string.
Clearly I am not assigning the string correctly, but I can't figure
out what I am
doing wrong. Any ideas ?
I have just started working with minimock in doctest.
I want to create a mock pyodbc object which returns a string value
when the method execute is called.
Here is my doctest:
.... ServerName = 'test_server'
.... DbName = 'test_database'
.... User = 'test_user'
.... Pass ='test_pass'
.... connstring ='DRIVER{SQL Server};SERVER=%s;DATABASE=%s;UID=
%s;PWD=%s;' % (ServerName,
.... DbName, User, Pass)
.... cnx = pyodbc.connect(connstring)
.... cur = cnx.cursor()
.... name = cur.execute("select user_id from user")
.... print 'name:%s' % name
....
Here is the output from doctest:
*****************************************************************************
File ".\pyodbc_test.txt", line 35, in pyodbc_test.txt
Failed example:
database_response() #doctest: +ELLIPSIS
Expected nothing
Got:
Called pyodbc.connect({DRIVER{SQLServer};
SERVER=test_server;DATABASE=test_database;UID=test_user;PWD=test_pass;')
Called pyodbc.cursor()
Called pyodbc.execute('select user_id from users')
name: None
*******************************************************************************************
The last line of the output, name : Name, should read, name: Return
this string.
Clearly I am not assigning the string correctly, but I can't figure
out what I am
doing wrong. Any ideas ?