I'm not quite sure how is this supposed to work, since the mehod is outside of the TestCase class
import unittest
import testing.postgresql
def tearDownModule(self):
Postgresql.clear_cache()
class Base(unittest.TestCase):
def setUp(self) -> None:
self.postgresql = Postgresql()
print(self.postgresql.url())
def tearDown(self) -> None:
self.postgresql.stop()
class TestInitial(Base):
def some_test_suite(self):
print('Test this works')
def some_test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestInitial))
return suite
if __name__ == '__main__':
with testing.postgresql.Postgresql() as postgresql:
engine = create_engine(postgresql.url())
db = psycopg2.connect(**postgresql.dsn())
runner = unittest.TextTestRunner()
runner.run(some_test_suite())
Next what happens is two things:
No application found. Either work inside a view function or push an application context. See http://flask-sqlalchemy.pocoo.org/contexts/.
and
ERROR: testing.common.database: failed to shutdown the server automatically. Any server processes and files might have been leaked. Please remove them and call the stop() certainly
Full log:
postgresql://postgres@127.0.0.1:47359/test
No application found. Either work inside a view function or push an application context. See http://flask-sqlalchemy.pocoo.org/contexts/.
.
----------------------------------------------------------------------
Ran 1 test in 0.807s
OK
ERROR: testing.common.database: failed to shutdown the server automatically.
Any server processes and files might have been leaked. Please remove them and call the stop() certainly
ERROR: testing.common.database: failed to shutdown the server automatically.
Any server processes and files might have been leaked. Please remove them and call the stop() certainly
I've been struggling with this for quite a while and I will appreciate any feedback. Thank you
Hello, the below appears when following the guide:
I'm not quite sure how is this supposed to work, since the mehod is outside of the TestCase class
Next what happens is two things:
No application found. Either work inside a view function or push an application context. See http://flask-sqlalchemy.pocoo.org/contexts/.
and
ERROR: testing.common.database: failed to shutdown the server automatically. Any server processes and files might have been leaked. Please remove them and call the stop() certainly
Full log:
I've been struggling with this for quite a while and I will appreciate any feedback. Thank you