Closed kardaj closed 8 years ago
I tried the your script as a test, then postgresql shutdown safely.
I used unittest.main()
, nosetests
and py.test
as test runners.
I added following testcase. It raises a simple exception.
def test_failed(self):
raise
Could you tell me your situation in detail?
After further analysis, I think it's more of a unittest problem. Here's some code that will generate a trailing test cluster:
import unittest
import testing.postgresql
class MyTestCase(unittest.TestCase):
@classmethod
def setUpClass(self):
print 'setUpClass'
self.postgresql = testing.postgresql.Postgresql()
import inexistingpackage
@classmethod
def tearDownClass(self):
print 'tearDownClass'
self.postgresql.stop()
def test_error(self):
cur.help()
def test_working(self):
'working test'
assert 1
In this code, an error occurred during the setup phase. This leads to unittest stopping and tearDownClass
not being called at all.
I understand.
Test runners skips tearDownClass
if setUpClass
got error. It's rule of unittest.TestCase
.
Please rewrite your setUpClass
like following:
@classmethod
def setUpClass(self):
print 'setUpClass'
try:
self.postgresql = testing.postgresql.Postgresql()
import inexistingpackage
except:
self.postgresql.stop()
I think this is not a bug of testing.postgresql
. so I close this.
Thanks,
Hi, I'm using the following snippet to run my tests.
The problem I'm currently having is that the testing postgres cluster doesn't shutdown if my test run into an Error. Is there a way to avoid this?