def test_maybe_finalize_headers(self, write_method): writer = HttpWriter(None, None, None, None) writer._maybe_send_headers() write_method.assert_called_with(b'\r\n') writer = HttpWriter(None, None, None, None) writer._headers_sent = True writer._maybe_send_headers() self.assertTrue(writer._headers_sent)
def test_write_header_raises_when_headers_sent(self): writer = HttpWriter(None, None, None, None) writer._headers_sent = True self.assertRaises(AssertionError, writer.write_header, b'foo', b'bar')