mjhea0 / flaskr-tdd

Flaskr: Intro to Flask, Test-Driven Development (TDD), and JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: What does passing self to test_client() do?

paxcodes opened this issue · comments

commented

In the first test (the simple "hello, world!" app) you passed self to app.test_client().

def test_index(self):
        tester = app.test_client(self)
        response = tester.get('/', content_type='html/text')

I also see it in "Second Test", "Database Setup", etc.

And then there are some tests that do not pass self

class FlaskrTestCase(unittest.TestCase):

    def setUp(self):
        """Set up a blank temp database before each test."""
        self.db_fd, app.app.config['DATABASE'] = tempfile.mkstemp()
        app.app.config['TESTING'] = True
        self.app = app.app.test_client()

I looked at the flask docs and I don't know how self could be passed on to test_client when its arguments are only the following: use_cookies=True, **kwargs

If I change test_client(self) to simply test_client(), the test still pass. So, what does passing self to test_client() do? (i.e. test_client(self))