def tester(request): """Tester fixture.""" class Handler(RequestHandler): def get(self): self.write('Hello') app = Application([url('/hello', Handler)]) tester = Tester(app) tester.setup() request.addfinalizer(tester.teardown) return tester
def test_reuse(): """Tester is not reusable.""" class Handler(RequestHandler): def get(self): self.write('Hello') app = Application([url('/hello', Handler)]) tester = Tester(app) with tester: response = yield tester.http_client.fetch(tester.url_for('/hello')) assert 'Hello' == text_body(response) with pytest.raises(RuntimeError): tester.setup()