assert actual == expected, actual def test_templating_skipped_without_script(): response = Response() expected = "{{ foo }}" actual = check("{{ foo }}", response=response) assert actual == expected, actual # _compute_paddings def test_compute_paddings_computes_paddings(): actual = DynamicResource._compute_paddings(['\n\n\n', '\n']) assert actual == ['', '\n\n\n'], actual def test_compute_paddings_computes_paddings_for_empty_list(): actual = DynamicResource._compute_paddings([]) assert actual == [], actual def test_compute_paddings_computes_paddings_for_more(): func = DynamicResource._compute_paddings actual = func(['\n\n\n', 'cheese', '\n\n\n\n\n\n', 'Monkey\nHead']) assert actual == ['', '\n\n\n', '', '\n\n\n\n\n\n'], actual # Teardown # ======== attach_teardown(globals())
def test_buffer_is_instantiable(): mk(('echo.sock', 'socket.send(socket.recv())')) expected = Buffer actual = Buffer(make_socket(), 'foo').__class__ assert actual is expected, actual def test_can_put_onto_buffer(): mk(('echo.sock', 'socket.send(socket.recv())')) buffer = Buffer(make_socket(), 'foo') expected = [FFFD+'4'+FFFD+'1:::'] buffer.put(Message.from_bytes('1:::')) actual = list(buffer.flush()) assert actual == expected, actual def test_buffer_flush_performance(): return # This test makes my lap hot. M = lambda: Message.from_bytes("3::/echo.sock:Greetings, program!") N = 10000 buffer = Buffer([M() for i in range(N)]) out = list(buffer.flush()) nbuffer = len(buffer) nout = len(out) assert nbuffer + nout == N, (nbuffer, nout) assert nout > 500 attach_teardown(globals())