Forums

Flask getting started with unittest

Hi, I have a simple working flask app I added test.py with the following code.

from flask_app import app
import unittest

class FlaskTestCase(unittest.TestCase):

    def test_index(self):
        tester = app.test.client(self)
        response = tester.get('/login', content_type='html/text')
        self.assertEqual(response.status_code, 200)

if __name__ == '__main__':
    unittest.main()

Everything is happy, but when I click the >>>run button it tells me:

Ran 0 tests in 0.000s

How do I get it to run the test.

It looks like a bug on our side. Run it in bash console with python3.7 test.py

I did have one bug in the above

tester = app.test.client(self)

should have been with underscore

tester = app_test.client(self)

Same message if I try and run from your >>>Run button. I does run fine as you suggested in a bash console thank you.