コード例 #1
0
ファイル: tests.py プロジェクト: andrewyoung1991/Nano
class Test(TestCase):
    def setUp(self):
        self.app = NanoApplication()
        self.setup()

    def setup(self):
        pass

    def assertContains(self, haystack, *needles):
        for needle in needles:
            self.assertIn(needle, haystack)

    def assertResponse(self, *args, **attrs):
        response = self.call_app(*args)
        for attr, value in attrs.iteritems():
            self.assertEqual(getattr(response, attr), value)

    def route(self, callback):
        self.app.route('/')(callback)
        return self

    def call_app(self, url='/', environ=None):
        class result: pass
        def start_response(status, headers):
            result.status, result.headers = status, dict(headers)
        if environ is None:
            environ = {}
        environ['PATH_INFO'] = url
        result.body = self.app(environ, start_response)
        return result
コード例 #2
0
ファイル: tests.py プロジェクト: pombredanne/Nano
 def setUp(self):
     self.app = NanoApplication()
     self.setup()