[Pyunit-interest] Problem with PyUnit and MySQL
Brought to you by:
purcell
From: Desilets, A. <Ala...@nr...> - 2006-12-19 19:35:07
|
Hi all, I'm trying to write PyUnit tests for an application that is based on = MySQL, and am experiencing some strange problems. Note that I am an = experienced PyUnit developer, but a complete newbie at MySQL. The short code snippet below illustrates the problem I'm having: =3D=3D Start code import MySQLdb import unittest print "-- finished server_init()" class MyTest(unittest.TestCase): def __init__(self, name): unittest.TestCase.__init__(self, name) def test_nevermind(self): self.fail("Nevermind. If I was able to get this far, it's good") arguments =3D \ ['Transana',=20 u'--datadir=3DC:\\Documents and Settings\\Desiletsa\\Application = Data\\Transana 2\\databases\\',=20 '--basedir=3D.',=20 '--language=3D./share/english'] =20 # Tests don't run unless you comment out the next line =20 MySQLdb.server_init(args=3Darguments) suite_to_run =3D unittest.TestSuite() suite_to_run.addTest(unittest.makeSuite(MyTest, 'test'))=20 print "-- running the tests" unittest.TextTestRunner().run(suite_to_run)=20 print "-- finished tests" =3D=3D=3D=3D End code Basically, I would expect this code to result in a a failed test. But = instead, I get the following on STDOUT: -- finished server_init() -- running the tests In other words, the tests never seem to be executed. The funny thing is that if I comment out the call to = MySQLdb.server_init(), and run the code again, I get the expected = output, i.e.: =3D=3D=3D=3D -- finished server_init() -- running the tests F =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D FAIL: test_nevermind (__main__.MyTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "pyUnit_with_MySQL_problem.py", line 11, in test_nevermind self.fail("Nevermind. If I was able to get this far, it's good") AssertionError: Nevermind. If I was able to get this far, it's good ---------------------------------------------------------------------- Ran 1 test in 0.000s FAILED (failures=3D1) -- finished tests =3D=3D=3D=3D Does anyone have an idea of what is going on here? Thx Alain D=E9silets |