How to write unit tests for python tornado application? : <p>I want to try to write some code following TDD practice. I want to create simple app based on python's tornado framework. I was looking through the internet how people write tests for tornado and found something like this:</p>

<pre><code>class TestSomeHandler(AsyncHTTPTestCase):
    def test_success(self):
        response = self.fetch('/something')
        self.assertEqual(response.code, 200)
</code></pre>

<p>Correct me if I'm wrong but it looks more like integration tests. Instead of it I'm trying to write simple unit test for some dummy handler. For example such one:</p>

<pre><code>class SomeHandler(BaseHandler):
    @gen.coroutine
    def get(self):
        try:
            from_date = self.get_query_argument("from", default=None)
            datetime.datetime.strptime(from_date, '%Y-%m-%d')
        except ValueError:
            raise ValueError("Incorrect argument value for from_date = %s, should be YYYY-MM-DD" % from_date)
</code></pre>

<p>And test would look like:</p>

<pre><code>class TestSomeHandler(AsyncHTTPTestCase):

    def test_no_from_date_param(self):
        handler = SomeHandler()
        with self.assertRaises(ValueError):
            handler.get()
</code></pre>

<p>I know I miss at <code>get()</code> application and request. Not handled yet how to create them.</p>

<p>But my question is, do people write tests for tornado like in first example or somebody calls handlers inside of app? What pattern to follow? It would be nice if somebody have relevant code to share. </p>
