buggy stringlengths 35 5.03k | fixed stringlengths 46 62.5k |
|---|---|
def test_multiple_requests_without_body(self):
self.sock = orig_sock
def test_without_crlf(self):
data = "Echo\nthis\r\nplease"
s = tobytes(
"GET / HTTP/1.0\n"
"Connection: close\n"
"Content-Length: %d\n"
"\n"
"%s" % (len(data), da... | def test_multiple_requests_without_body(self):
self.sock = orig_sock
def test_without_crlf(self):
data = "Echo\r\nthis\r\nplease"
s = tobytes(
"GET / HTTP/1.0\r\n"
"Connection: close\r\n"
"Content-Length: %d\r\n"
"\r\n"
"%s" % (len... |
def test_large_body(self):
# 1024 characters.
body = "This string has 32 characters.\r\n" * 32
s = tobytes(
"GET / HTTP/1.0\n" "Content-Length: %d\n" "\n" "%s" % (len(body), body)
)
self.connect()
self.sock.send(s) | def test_large_body(self):
# 1024 characters.
body = "This string has 32 characters.\r\n" * 32
s = tobytes(
"GET / HTTP/1.0\r\nContent-Length: %d\r\n\r\n%s" % (len(body), body)
)
self.connect()
self.sock.send(s) |
def test_many_clients(self):
h.close()
def test_chunking_request_without_content(self):
header = tobytes("GET / HTTP/1.1\n" "Transfer-Encoding: chunked\n\n")
self.connect()
self.sock.send(header)
self.sock.send(b"0\r\n\r\n") | def test_many_clients(self):
h.close()
def test_chunking_request_without_content(self):
header = tobytes("GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n")
self.connect()
self.sock.send(header)
self.sock.send(b"0\r\n\r\n") |
def test_chunking_request_with_content(self):
control_line = b"20;\r\n" # 20 hex = 32 dec
s = b"This string has 32 characters.\r\n"
expected = s * 12
header = tobytes("GET / HTTP/1.1\n" "Transfer-Encoding: chunked\n\n")
self.connect()
self.sock.send(header)
fp = ... | def test_chunking_request_with_content(self):
control_line = b"20;\r\n" # 20 hex = 32 dec
s = b"This string has 32 characters.\r\n"
expected = s * 12
header = tobytes("GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n")
self.connect()
self.sock.send(header)
fp... |
def test_chunking_request_with_content(self):
def test_broken_chunked_encoding(self):
control_line = "20;\r\n" # 20 hex = 32 dec
s = "This string has 32 characters.\r\n"
to_send = "GET / HTTP/1.1\nTransfer-Encoding: chunked\n\n"
to_send += control_line + s
# garbage in input... | def test_chunking_request_with_content(self):
def test_broken_chunked_encoding(self):
control_line = "20;\r\n" # 20 hex = 32 dec
s = "This string has 32 characters.\r\n"
to_send = "GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n"
to_send += control_line + s + "\r\n"
# g... |
def test_broken_chunked_encoding(self):
self.assertline(line, "400", "Bad Request", "HTTP/1.1")
cl = int(headers["content-length"])
self.assertEqual(cl, len(response_body))
self.assertEqual(
sorted(headers.keys()), ["connection", "content-length", "content-type", "date", "ser... | def test_broken_chunked_encoding(self):
self.assertline(line, "400", "Bad Request", "HTTP/1.1")
cl = int(headers["content-length"])
self.assertEqual(cl, len(response_body))
self.assertTrue(b"Chunk not properly terminated" in response_body)
self.assertEqual(
sorted(hea... |
def test_keepalive_http_10(self):
# Handling of Keep-Alive within HTTP 1.0
data = "Default: Don't keep me alive"
s = tobytes(
"GET / HTTP/1.0\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data)
)
self.connect()
self.sock.send(s) | def test_keepalive_http_10(self):
# Handling of Keep-Alive within HTTP 1.0
data = "Default: Don't keep me alive"
s = tobytes(
"GET / HTTP/1.0\r\nContent-Length: %d\r\n\r\n%s" % (len(data), data)
)
self.connect()
self.sock.send(s) |
def test_keepalive_http10_explicit(self):
# the corresponding header
data = "Keep me alive"
s = tobytes(
"GET / HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: %d\n"
"\n"
"%s" % (len(data), data)
)
self.connect() | def test_keepalive_http10_explicit(self):
# the corresponding header
data = "Keep me alive"
s = tobytes(
"GET / HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: %d\r\n"
"\r\n"
"%s" % (len(data), data)
)
self.c... |
def test_keepalive_http_11(self):
# All connections are kept alive, unless stated otherwise
data = "Default: Keep me alive"
s = tobytes(
"GET / HTTP/1.1\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data)
)
self.connect()
self.sock.send(s) | def test_keepalive_http_11(self):
# All connections are kept alive, unless stated otherwise
data = "Default: Keep me alive"
s = tobytes(
"GET / HTTP/1.1\r\nContent-Length: %d\r\n\r\n%s" % (len(data), data)
)
self.connect()
self.sock.send(s) |
def test_keepalive_http11_explicit(self):
# Explicitly set keep-alive
data = "Default: Keep me alive"
s = tobytes(
"GET / HTTP/1.1\n"
"Connection: keep-alive\n"
"Content-Length: %d\n"
"\n"
"%s" % (len(data), data)
)
self... | def test_keepalive_http11_explicit(self):
# Explicitly set keep-alive
data = "Default: Keep me alive"
s = tobytes(
"GET / HTTP/1.1\r\n"
"Connection: keep-alive\r\n"
"Content-Length: %d\r\n"
"\r\n"
"%s" % (len(data), data)
)
... |
def test_keepalive_http11_connclose(self):
# specifying Connection: close explicitly
data = "Don't keep me alive"
s = tobytes(
"GET / HTTP/1.1\n"
"Connection: close\n"
"Content-Length: %d\n"
"\n"
"%s" % (len(data), data)
)
... | def test_keepalive_http11_connclose(self):
# specifying Connection: close explicitly
data = "Don't keep me alive"
s = tobytes(
"GET / HTTP/1.1\r\n"
"Connection: close\r\n"
"Content-Length: %d\r\n"
"\r\n"
"%s" % (len(data), data)
... |
def test_keepalive_http11_connclose(self):
def test_proxy_headers(self):
to_send = (
"GET / HTTP/1.0\n"
"Content-Length: 0\n"
"Host: www.google.com:8080\n"
"X-Forwarded-For: 192.168.1.1\n"
"X-Forwarded-Proto: https\n"
"X-Forwarded-Port... | def test_keepalive_http11_connclose(self):
def test_proxy_headers(self):
to_send = (
"GET / HTTP/1.0\r\n"
"Content-Length: 0\r\n"
"Host: www.google.com:8080\r\n"
"X-Forwarded-For: 192.168.1.1\r\n"
"X-Forwarded-Proto: https\r\n"
"X-Forw... |
def test_expect_continue(self):
# specifying Connection: close explicitly
data = "I have expectations"
to_send = tobytes(
"GET / HTTP/1.1\n"
"Connection: close\n"
"Content-Length: %d\n"
"Expect: 100-continue\n"
"\n"
"%s" % (... | def test_expect_continue(self):
# specifying Connection: close explicitly
data = "I have expectations"
to_send = tobytes(
"GET / HTTP/1.1\r\n"
"Connection: close\r\n"
"Content-Length: %d\r\n"
"Expect: 100-continue\r\n"
"\r\n"
... |
def test_short_body(self):
# check to see if server closes connection when body is too short
# for cl header
to_send = tobytes(
"GET /short_body HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: 0\n"
"\n"
)
self.connect()
... | def test_short_body(self):
# check to see if server closes connection when body is too short
# for cl header
to_send = tobytes(
"GET /short_body HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: 0\r\n"
"\r\n"
)
self.connec... |
def test_long_body(self):
# check server doesnt close connection when body is too short
# for cl header
to_send = tobytes(
"GET /long_body HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: 0\n"
"\n"
)
self.connect()
se... | def test_long_body(self):
# check server doesnt close connection when body is too short
# for cl header
to_send = tobytes(
"GET /long_body HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: 0\r\n"
"\r\n"
)
self.connect()
... |
def tearDown(self):
def test_http10_generator(self):
body = string.ascii_letters
to_send = (
"GET / HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: %d\n\n" % len(body)
)
to_send += body
to_send = tobytes(to_send) | def tearDown(self):
def test_http10_generator(self):
body = string.ascii_letters
to_send = (
"GET / HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: %d\r\n\r\n" % len(body)
)
to_send += body
to_send = tobytes(to_send) |
def test_http10_generator(self):
def test_http10_list(self):
body = string.ascii_letters
to_send = (
"GET /list HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: %d\n\n" % len(body)
)
to_send += body
to_send = tobytes(to_send) | def test_http10_generator(self):
def test_http10_list(self):
body = string.ascii_letters
to_send = (
"GET /list HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: %d\r\n\r\n" % len(body)
)
to_send += body
to_send = tobytes(to_send) |
def test_http10_list(self):
def test_http10_listlentwo(self):
body = string.ascii_letters
to_send = (
"GET /list_lentwo HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: %d\n\n" % len(body)
)
to_send += body
to_send = tobytes(to_send) | def test_http10_list(self):
def test_http10_listlentwo(self):
body = string.ascii_letters
to_send = (
"GET /list_lentwo HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: %d\r\n\r\n" % len(body)
)
to_send += body
to_send = tobytes(... |
def test_http10_listlentwo(self):
def test_http11_generator(self):
body = string.ascii_letters
to_send = "GET / HTTP/1.1\n" "Content-Length: %s\n\n" % len(body)
to_send += body
to_send = tobytes(to_send)
self.connect() | def test_http10_listlentwo(self):
def test_http11_generator(self):
body = string.ascii_letters
to_send = "GET / HTTP/1.1\r\nContent-Length: %s\r\n\r\n" % len(body)
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_http11_generator(self):
def test_http11_list(self):
body = string.ascii_letters
to_send = "GET /list HTTP/1.1\n" "Content-Length: %d\n\n" % len(body)
to_send += body
to_send = tobytes(to_send)
self.connect() | def test_http11_generator(self):
def test_http11_list(self):
body = string.ascii_letters
to_send = "GET /list HTTP/1.1\r\nContent-Length: %d\r\n\r\n" % len(body)
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_http11_list(self):
def test_http11_listlentwo(self):
body = string.ascii_letters
to_send = "GET /list_lentwo HTTP/1.1\n" "Content-Length: %s\n\n" % len(body)
to_send += body
to_send = tobytes(to_send)
self.connect() | def test_http11_list(self):
def test_http11_listlentwo(self):
body = string.ascii_letters
to_send = "GET /list_lentwo HTTP/1.1\r\nContent-Length: %s\r\n\r\n" % len(body)
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_short_body(self):
# check to see if server closes connection when body is too short
# for cl header
to_send = tobytes(
"GET /short_body HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: 0\n"
"\n"
)
self.connect()
... | def test_short_body(self):
# check to see if server closes connection when body is too short
# for cl header
to_send = tobytes(
"GET /short_body HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: 0\r\n"
"\r\n"
)
self.connec... |
def test_long_body(self):
# check server doesnt close connection when body is too long
# for cl header
to_send = tobytes(
"GET /long_body HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: 0\n"
"\n"
)
self.connect()
sel... | def test_long_body(self):
# check server doesnt close connection when body is too long
# for cl header
to_send = tobytes(
"GET /long_body HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: 0\r\n"
"\r\n"
)
self.connect()
... |
def test_equal_body(self):
# check server doesnt close connection when body is equal to
# cl header
to_send = tobytes(
"GET /equal_body HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: 0\n"
"\n"
)
self.connect()
self.... | def test_equal_body(self):
# check server doesnt close connection when body is equal to
# cl header
to_send = tobytes(
"GET /equal_body HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: 0\r\n"
"\r\n"
)
self.connect()
... |
def test_equal_body(self):
def test_no_content_length(self):
# wtf happens when there's no content-length
to_send = tobytes(
"GET /no_content_length HTTP/1.0\n"
"Connection: Keep-Alive\n"
"Content-Length: 0\n"
"\n"
)
self.connect()
... | def test_equal_body(self):
def test_no_content_length(self):
# wtf happens when there's no content-length
to_send = tobytes(
"GET /no_content_length HTTP/1.0\r\n"
"Connection: Keep-Alive\r\n"
"Content-Length: 0\r\n"
"\r\n"
)
self.connec... |
def tearDown(self):
def test_request_body_too_large_with_wrong_cl_http10(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.0\n" "Content-Length: 5\n\n"
to_send += body
to_send = tobytes(to_send)
self.connect() | def tearDown(self):
def test_request_body_too_large_with_wrong_cl_http10(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.0\r\nContent-Length: 5\r\n\r\n"
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_request_body_too_large_with_wrong_cl_http10(self):
def test_request_body_too_large_with_wrong_cl_http10_keepalive(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.0\n" "Content-Length: 5\n" "Connection: Keep-Alive\n\n"
to_send += body
to_send = tobytes(to_send)
... | def test_request_body_too_large_with_wrong_cl_http10(self):
def test_request_body_too_large_with_wrong_cl_http10_keepalive(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.0\r\nContent-Length: 5\r\nConnection: Keep-Alive\r\n\r\n"
to_send += body
to_send = tobytes(to_send)
... |
def test_request_body_too_large_with_wrong_cl_http10_keepalive(self):
def test_request_body_too_large_with_no_cl_http10(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.0\n\n"
to_send += body
to_send = tobytes(to_send)
self.connect() | def test_request_body_too_large_with_wrong_cl_http10_keepalive(self):
def test_request_body_too_large_with_no_cl_http10(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.0\r\n\r\n"
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_request_body_too_large_with_no_cl_http10(self):
def test_request_body_too_large_with_no_cl_http10_keepalive(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.0\nConnection: Keep-Alive\n\n"
to_send += body
to_send = tobytes(to_send)
self.connect() | def test_request_body_too_large_with_no_cl_http10(self):
def test_request_body_too_large_with_no_cl_http10_keepalive(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.0\r\nConnection: Keep-Alive\r\n\r\n"
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_request_body_too_large_with_no_cl_http10_keepalive(self):
def test_request_body_too_large_with_wrong_cl_http11(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.1\n" "Content-Length: 5\n\n"
to_send += body
to_send = tobytes(to_send)
self.connect() | def test_request_body_too_large_with_no_cl_http10_keepalive(self):
def test_request_body_too_large_with_wrong_cl_http11(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.1\r\nContent-Length: 5\r\n\r\n"
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_request_body_too_large_with_wrong_cl_http11(self):
def test_request_body_too_large_with_wrong_cl_http11_connclose(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.1\nContent-Length: 5\nConnection: close\n\n"
to_send += body
to_send = tobytes(to_send)
self.con... | def test_request_body_too_large_with_wrong_cl_http11(self):
def test_request_body_too_large_with_wrong_cl_http11_connclose(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.1\r\nContent-Length: 5\r\nConnection: close\r\n\r\n"
to_send += body
to_send = tobytes(to_send)
... |
def test_request_body_too_large_with_wrong_cl_http11_connclose(self):
def test_request_body_too_large_with_no_cl_http11(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.1\n\n"
to_send += body
to_send = tobytes(to_send)
self.connect() | def test_request_body_too_large_with_wrong_cl_http11_connclose(self):
def test_request_body_too_large_with_no_cl_http11(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.1\r\n\r\n"
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_request_body_too_large_with_no_cl_http11(self):
def test_request_body_too_large_with_no_cl_http11_connclose(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.1\nConnection: close\n\n"
to_send += body
to_send = tobytes(to_send)
self.connect() | def test_request_body_too_large_with_no_cl_http11(self):
def test_request_body_too_large_with_no_cl_http11_connclose(self):
body = "a" * self.toobig
to_send = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n"
to_send += body
to_send = tobytes(to_send)
self.connect() |
def test_request_body_too_large_with_no_cl_http11_connclose(self):
def test_request_body_too_large_chunked_encoding(self):
control_line = "20;\r\n" # 20 hex = 32 dec
s = "This string has 32 characters.\r\n"
to_send = "GET / HTTP/1.1\nTransfer-Encoding: chunked\n\n"
repeat = control_... | def test_request_body_too_large_with_no_cl_http11_connclose(self):
def test_request_body_too_large_chunked_encoding(self):
control_line = "20;\r\n" # 20 hex = 32 dec
s = "This string has 32 characters.\r\n"
to_send = "GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n"
repeat = co... |
def tearDown(self):
self.stop_subprocess()
def test_before_start_response_http_10(self):
to_send = "GET /before_start_response HTTP/1.0\n\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) | def tearDown(self):
self.stop_subprocess()
def test_before_start_response_http_10(self):
to_send = "GET /before_start_response HTTP/1.0\r\n\r\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) |
def test_before_start_response_http_10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_before_start_response_http_11(self):
to_send = "GET /before_start_response HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) | def test_before_start_response_http_10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_before_start_response_http_11(self):
to_send = "GET /before_start_response HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) |
def test_before_start_response_http_11(self):
def test_before_start_response_http_11_close(self):
to_send = tobytes(
"GET /before_start_response HTTP/1.1\n" "Connection: close\n\n"
)
self.connect()
self.sock.send(to_send) | def test_before_start_response_http_11(self):
def test_before_start_response_http_11_close(self):
to_send = tobytes(
"GET /before_start_response HTTP/1.1\r\nConnection: close\r\n\r\n"
)
self.connect()
self.sock.send(to_send) |
def test_before_start_response_http_11_close(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_after_start_response_http10(self):
to_send = "GET /after_start_response HTTP/1.0\n\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) | def test_before_start_response_http_11_close(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_after_start_response_http10(self):
to_send = "GET /after_start_response HTTP/1.0\r\n\r\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) |
def test_after_start_response_http10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_after_start_response_http11(self):
to_send = "GET /after_start_response HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) | def test_after_start_response_http10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_after_start_response_http11(self):
to_send = "GET /after_start_response HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) |
def test_after_start_response_http11(self):
def test_after_start_response_http11_close(self):
to_send = tobytes(
"GET /after_start_response HTTP/1.1\n" "Connection: close\n\n"
)
self.connect()
self.sock.send(to_send) | def test_after_start_response_http11(self):
def test_after_start_response_http11_close(self):
to_send = tobytes(
"GET /after_start_response HTTP/1.1\r\nConnection: close\r\n\r\n"
)
self.connect()
self.sock.send(to_send) |
def test_after_start_response_http11_close(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_after_write_cb(self):
to_send = "GET /after_write_cb HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) | def test_after_start_response_http11_close(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_after_write_cb(self):
to_send = "GET /after_write_cb HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) |
def test_after_write_cb(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_in_generator(self):
to_send = "GET /in_generator HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) | def test_after_write_cb(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_in_generator(self):
to_send = "GET /in_generator HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect()
self.sock.send(to_send) |
def tearDown(self):
self.stop_subprocess()
def test_filelike_http11(self):
to_send = "GET /filelike HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def tearDown(self):
self.stop_subprocess()
def test_filelike_http11(self):
to_send = "GET /filelike HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_filelike_http11(self):
# connection has not been closed
def test_filelike_nocl_http11(self):
to_send = "GET /filelike_nocl HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def test_filelike_http11(self):
# connection has not been closed
def test_filelike_nocl_http11(self):
to_send = "GET /filelike_nocl HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_filelike_nocl_http11(self):
# connection has not been closed
def test_filelike_shortcl_http11(self):
to_send = "GET /filelike_shortcl HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def test_filelike_nocl_http11(self):
# connection has not been closed
def test_filelike_shortcl_http11(self):
to_send = "GET /filelike_shortcl HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_filelike_shortcl_http11(self):
# connection has not been closed
def test_filelike_longcl_http11(self):
to_send = "GET /filelike_longcl HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def test_filelike_shortcl_http11(self):
# connection has not been closed
def test_filelike_longcl_http11(self):
to_send = "GET /filelike_longcl HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_filelike_longcl_http11(self):
# connection has not been closed
def test_notfilelike_http11(self):
to_send = "GET /notfilelike HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def test_filelike_longcl_http11(self):
# connection has not been closed
def test_notfilelike_http11(self):
to_send = "GET /notfilelike HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_notfilelike_http11(self):
# connection has not been closed
def test_notfilelike_iobase_http11(self):
to_send = "GET /notfilelike_iobase HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def test_notfilelike_http11(self):
# connection has not been closed
def test_notfilelike_iobase_http11(self):
to_send = "GET /notfilelike_iobase HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_notfilelike_iobase_http11(self):
# connection has not been closed
def test_notfilelike_nocl_http11(self):
to_send = "GET /notfilelike_nocl HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def test_notfilelike_iobase_http11(self):
# connection has not been closed
def test_notfilelike_nocl_http11(self):
to_send = "GET /notfilelike_nocl HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_notfilelike_nocl_http11(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_notfilelike_shortcl_http11(self):
to_send = "GET /notfilelike_shortcl HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def test_notfilelike_nocl_http11(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_notfilelike_shortcl_http11(self):
to_send = "GET /notfilelike_shortcl HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_notfilelike_shortcl_http11(self):
# connection has not been closed
def test_notfilelike_longcl_http11(self):
to_send = "GET /notfilelike_longcl HTTP/1.1\n\n"
to_send = tobytes(to_send)
self.connect() | def test_notfilelike_shortcl_http11(self):
# connection has not been closed
def test_notfilelike_longcl_http11(self):
to_send = "GET /notfilelike_longcl HTTP/1.1\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_notfilelike_longcl_http11(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_filelike_http10(self):
to_send = "GET /filelike HTTP/1.0\n\n"
to_send = tobytes(to_send)
self.connect() | def test_notfilelike_longcl_http11(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_filelike_http10(self):
to_send = "GET /filelike HTTP/1.0\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_filelike_http10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_filelike_nocl_http10(self):
to_send = "GET /filelike_nocl HTTP/1.0\n\n"
to_send = tobytes(to_send)
self.connect() | def test_filelike_http10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_filelike_nocl_http10(self):
to_send = "GET /filelike_nocl HTTP/1.0\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_filelike_nocl_http10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_notfilelike_http10(self):
to_send = "GET /notfilelike HTTP/1.0\n\n"
to_send = tobytes(to_send)
self.connect() | def test_filelike_nocl_http10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_notfilelike_http10(self):
to_send = "GET /notfilelike HTTP/1.0\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def test_notfilelike_http10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_notfilelike_nocl_http10(self):
to_send = "GET /notfilelike_nocl HTTP/1.0\n\n"
to_send = tobytes(to_send)
self.connect() | def test_notfilelike_http10(self):
self.assertRaises(ConnectionClosed, read_http, fp)
def test_notfilelike_nocl_http10(self):
to_send = "GET /notfilelike_nocl HTTP/1.0\r\n\r\n"
to_send = tobytes(to_send)
self.connect() |
def read_http(fp): # pragma: no cover
header_lines = []
while True:
line = fp.readline()
if line in (b"\r\n", b"\n", b""):
break
else:
header_lines.append(line) | def read_http(fp): # pragma: no cover
header_lines = []
while True:
line = fp.readline()
if line in (b"\r\n", b"\r\n", b""):
break
else:
header_lines.append(line) |
"""
import unittest
from waitress.compat import (
text_,
tobytes,
)
class TestHTTPRequestParser(unittest.TestCase): | """
import unittest
from waitress.compat import text_, tobytes
class TestHTTPRequestParser(unittest.TestCase): |
def test_get_body_stream_nonNone(self):
result = self.parser.get_body_stream()
self.assertEqual(result, body_rcv)
def test_received_nonsense_with_double_cr(self):
data = b"""\
HTTP/1.0 GET /foobar
"""
result = self.parser.received(data)
self.assertEqual(result, 22)
... | def test_get_body_stream_nonNone(self):
result = self.parser.get_body_stream()
self.assertEqual(result, body_rcv)
def test_received_get_no_headers(self):
data = b"HTTP/1.0 GET /foobar\r\n\r\n"
result = self.parser.received(data)
self.assertEqual(result, 24)
self.asse... |
def test_received_cl_too_large(self):
from waitress.utilities import RequestEntityTooLarge
self.parser.adj.max_request_body_size = 2
data = b"""\
GET /foobar HTTP/8.4
Content-Length: 10
"""
result = self.parser.received(data)
self.assertEqual(result, 41)
self.assertTrue... | def test_received_cl_too_large(self):
from waitress.utilities import RequestEntityTooLarge
self.parser.adj.max_request_body_size = 2
data = b"GET /foobar HTTP/8.4\r\nContent-Length: 10\r\n\r\n"
result = self.parser.received(data)
self.assertEqual(result, 44)
self.assertT... |
def test_received_headers_too_large(self):
from waitress.utilities import RequestHeaderFieldsTooLarge
self.parser.adj.max_request_header_size = 2
data = b"""\
GET /foobar HTTP/8.4
X-Foo: 1
"""
result = self.parser.received(data)
self.assertEqual(result, 30)
self.assertTr... | def test_received_headers_too_large(self):
from waitress.utilities import RequestHeaderFieldsTooLarge
self.parser.adj.max_request_header_size = 2
data = b"GET /foobar HTTP/8.4\r\nX-Foo: 1\r\n\r\n"
result = self.parser.received(data)
self.assertEqual(result, 34)
self.asse... |
def test_received_body_too_large(self):
from waitress.utilities import RequestEntityTooLarge
self.parser.adj.max_request_body_size = 2
data = b"""\
GET /foobar HTTP/1.1
Transfer-Encoding: chunked
X-Foo: 1
20;\r\n
This string has 32 characters\r\n
0\r\n\r\n"""
result = self.parser.recei... | def test_received_body_too_large(self):
from waitress.utilities import RequestEntityTooLarge
self.parser.adj.max_request_body_size = 2
data = (
b"GET /foobar HTTP/1.1\r\n"
b"Transfer-Encoding: chunked\r\n"
b"X-Foo: 1\r\n"
b"\r\n"
b"1d;... |
def test_received_body_too_large(self):
def test_received_error_from_parser(self):
from waitress.utilities import BadRequest
data = b"""\
GET /foobar HTTP/1.1
Transfer-Encoding: chunked
X-Foo: 1
garbage
"""
# header
result = self.parser.received(data)
# body
result ... | def test_received_body_too_large(self):
def test_received_error_from_parser(self):
from waitress.utilities import BadRequest
data = (
b"GET /foobar HTTP/1.1\r\n"
b"Transfer-Encoding: chunked\r\n"
b"X-Foo: 1\r\n"
b"\r\n"
b"garbage\r\n"
... |
def test_close_with_no_body_rcv(self):
self.parser.body_rcv = None
self.parser.close() # doesn't raise
class Test_split_uri(unittest.TestCase):
def _callFUT(self, uri): | def test_close_with_no_body_rcv(self):
self.parser.body_rcv = None
self.parser.close() # doesn't raise
def test_parse_header_lf_only(self):
from waitress.parser import ParsingError
data = b"GET /foobar HTTP/8.4\nfoo: bar"
try:
self.parser.parse_header(data)
... |
def _callFUT(self, data):
return get_header_lines(data)
def test_get_header_lines(self):
result = self._callFUT(b"slam\nslim")
self.assertEqual(result, [b"slam", b"slim"])
def test_get_header_lines_folded(self): | def _callFUT(self, data):
return get_header_lines(data)
def test_get_header_lines(self):
result = self._callFUT(b"slam\r\nslim")
self.assertEqual(result, [b"slam", b"slim"])
def test_get_header_lines_folded(self): |
def test_get_header_lines_folded(self):
# interpreting the field value or forwarding the message downstream.
# We are just preserving the whitespace that indicates folding.
result = self._callFUT(b"slim\n slam")
self.assertEqual(result, [b"slim slam"])
def test_get_header_lines_tab... | def test_get_header_lines_folded(self):
# interpreting the field value or forwarding the message downstream.
# We are just preserving the whitespace that indicates folding.
result = self._callFUT(b"slim\r\n slam")
self.assertEqual(result, [b"slim slam"])
def test_get_header_lines_t... |
def setUp(self):
def feed(self, data):
parser = self.parser
for n in range(100): # make sure we never loop forever
consumed = parser.received(data)
data = data[consumed:]
if parser.completed:
return
raise ValueError("Looping") # pragma: ... | def setUp(self):
def feed(self, data):
parser = self.parser
for n in range(100): # make sure we never loop forever
consumed = parser.received(data)
data = data[consumed:]
if parser.completed:
return
raise ValueError("Looping") # pragma... |
def testSimpleGET(self):
self.assertFalse(parser.empty)
self.assertEqual(
parser.headers,
{"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "7",},
)
self.assertEqual(parser.path, "/foobar")
self.assertEqual(parser.command, "GET")
self.... | def testSimpleGET(self):
self.assertFalse(parser.empty)
self.assertEqual(
parser.headers,
{"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "6",},
)
self.assertEqual(parser.path, "/foobar")
self.assertEqual(parser.command, "GET")
self.... |
def testComplexGET(self):
self.assertFalse(parser.empty)
self.assertEqual(
parser.headers,
{"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "10",},
)
# path should be utf-8 encoded
self.assertEqual( | def testComplexGET(self):
self.assertFalse(parser.empty)
self.assertEqual(
parser.headers,
{"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "10"},
)
# path should be utf-8 encoded
self.assertEqual( |
def testComplexGET(self):
self.assertEqual(parser.get_body_stream().getvalue(), b"Hello mick")
def testProxyGET(self):
data = b"""\
GET https://example.com:8080/foobar HTTP/8.4
content-length: 7
Hello.
"""
parser = self.parser
self.feed(data)
self.assertTrue(parser.complete... | def testComplexGET(self):
self.assertEqual(parser.get_body_stream().getvalue(), b"Hello mick")
def testProxyGET(self):
data = (
b"GET https://example.com:8080/foobar HTTP/8.4\r\n"
b"content-length: 6\r\n"
b"\r\n"
b"Hello."
)
parser = s... |
def test_received_control_line_notfinished(self):
def test_received_control_line_finished_garbage_in_input(self):
buf = DummyBuffer()
inst = self._makeOne(buf)
result = inst.received(b"garbage\n")
self.assertEqual(result, 8)
self.assertTrue(inst.error)
def test_received_... | def test_received_control_line_notfinished(self):
def test_received_control_line_finished_garbage_in_input(self):
buf = DummyBuffer()
inst = self._makeOne(buf)
result = inst.received(b"garbage\r\n")
self.assertEqual(result, 9)
self.assertTrue(inst.error)
def test_receive... |
def test_received_trailer_startswith_lf(self):
inst.all_chunks_received = True
result = inst.received(b"\n")
self.assertEqual(result, 1)
self.assertEqual(inst.completed, True)
def test_received_trailer_not_finished(self):
buf = DummyBuffer() | def test_received_trailer_startswith_lf(self):
inst.all_chunks_received = True
result = inst.received(b"\n")
self.assertEqual(result, 1)
self.assertEqual(inst.completed, False)
def test_received_trailer_not_finished(self):
buf = DummyBuffer() |
def test___len__(self):
inst = self._makeOne(buf)
self.assertEqual(inst.__len__(), 2)
class DummyBuffer(object):
def __init__(self, data=None): | def test___len__(self):
inst = self._makeOne(buf)
self.assertEqual(inst.__len__(), 2)
def test_received_chunk_is_properly_terminated(self):
buf = DummyBuffer()
inst = self._makeOne(buf)
data = b"4\r\nWiki\r\n"
result = inst.received(data)
self.assertEqual(res... |
def test_one_linefeed(self):
self.assertEqual(self._callFUT(b"\n"), -1)
def test_double_linefeed(self):
self.assertEqual(self._callFUT(b"\n\n"), 2)
def test_one_crlf(self):
self.assertEqual(self._callFUT(b"\r\n"), -1) | def test_one_linefeed(self):
self.assertEqual(self._callFUT(b"\n"), -1)
def test_double_linefeed(self):
self.assertEqual(self._callFUT(b"\n\n"), -1)
def test_one_crlf(self):
self.assertEqual(self._callFUT(b"\r\n"), -1) |
def test_double_crfl(self):
self.assertEqual(self._callFUT(b"\r\n\r\n"), 4)
def test_mixed(self):
self.assertEqual(self._callFUT(b"\n\n00\r\n\r\n"), 2)
class TestBadRequest(unittest.TestCase): | def test_double_crfl(self):
self.assertEqual(self._callFUT(b"\r\n\r\n"), 4)
def test_mixed(self):
self.assertEqual(self._callFUT(b"\n\n00\r\n\r\n"), 8)
class TestBadRequest(unittest.TestCase): |
def find_double_newline(s):
"""Returns the position just after a double newline in the given string."""
pos1 = s.find(b"\n\r\n") # One kind of double newline
if pos1 >= 0:
pos1 += 3
pos2 = s.find(b"\n\n") # Another kind of double newline
if pos2 >= 0:
pos2 += 2
if pos1 >= 0:
... |
def find_double_newline(s):
"""Returns the position just after a double newline in the given string."""
pos = s.find(b"\r\n\r\n")
if pos >= 0:
pos += 4
return pos
def concat(*args): |
def test_getproxies_environment_keep_no_proxies(self):
self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888'))
self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234'))
def test_proxy_bypass_environment_host_match(self):
bypass = urllib.proxy_bypass_environme... | def test_getproxies_environment_keep_no_proxies(self):
self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888'))
self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234'))
def test_proxy_cgi_ignore(self):
try:
self.env.set('HTTP_PROXY', 'http://somew... |
def getproxies_environment():
If you need a different way, you can pass a proxies dictionary to the
[Fancy]URLopener constructor.
"""
proxies = {}
for name, value in os.environ.items():
name = name.lower()
if value and name[-6:] == '_proxy':
proxies[name[:-6]] = value
... | def getproxies_environment():
If you need a different way, you can pass a proxies dictionary to the
[Fancy]URLopener constructor.
"""
# Get all variables
proxies = {}
for name, value in os.environ.items():
name = name.lower()
if value and name[-6:] == '_proxy':
proxie... |
class NDFrame(PandasObject, SelectionMixin):
"""
inplace = validate_bool_kwarg(inplace, "inplace")
if axis == 0:
ax = self._info_axis_name
_maybe_transposed_self = self
elif axis == 1:
_maybe_transposed_self = self.T
ax = 1
else:
... | class NDFrame(PandasObject, SelectionMixin):
"""
inplace = validate_bool_kwarg(inplace, "inplace")
axis = self._get_axis_number(axis)
if axis == 0:
ax = self._info_axis_name
_maybe_transposed_self = self
elif axis == 1:
_maybe_transposed_self... |
class TestDataFrameMissingData:
cat = Categorical([np.nan, 2, np.nan])
val = Categorical([np.nan, np.nan, np.nan])
df = DataFrame({"cats": cat, "vals": val})
res = df.fillna(df.median())
v_exp = [np.nan, np.nan, np.nan]
df_exp = DataFrame({"cats": [2, 2, 2], "vals": v_exp... | class TestDataFrameMissingData:
cat = Categorical([np.nan, 2, np.nan])
val = Categorical([np.nan, np.nan, np.nan])
df = DataFrame({"cats": cat, "vals": val})
with tm.assert_produces_warning(RuntimeWarning):
res = df.fillna(df.median())
v_exp = [np.nan, np.nan, np.nan]... |
class TestDataFrameInterpolate:
expected = df.interpolate()
assert_frame_equal(result, expected)
def test_rowwise_alt(self):
df = DataFrame(
{ | class TestDataFrameInterpolate:
expected = df.interpolate()
assert_frame_equal(result, expected)
@pytest.mark.parametrize(
"axis_name, axis_number",
[
pytest.param("rows", 0, id="rows_0"),
pytest.param("index", 0, id="index_0"),
pytest.param("colu... |
options:
description:
- Whether to disable the GPG checking of signatures of packages being
installed. Has an effect only if state is I(present) or I(latest).
type: bool
default: 'no'
| options:
description:
- Whether to disable the GPG checking of signatures of packages being
installed. Has an effect only if state is I(present) or I(latest).
- This setting affects packages installed from a repository as well as
"local" packages installed from the filesystem or a URL.
... |
class DnfModule(YumDnf):
results=[],
)
if self.download_only:
for package in self.base.transaction.install_set:
response['results'].append("Downloaded: {0}".format(package)) | class DnfModule(YumDnf):
results=[],
)
# Validate GPG. This is NOT done in dnf.Base (it's done in the
# upstream CLI subclass of dnf.Base)
if not self.disable_gpg_check:
for package in self.base.transaction.... |
def _get_empty_dtype_and_na(join_units):
dtype = upcast_classes["datetimetz"]
return dtype[0], tslibs.NaT
elif "datetime" in upcast_classes:
return np.dtype("M8[ns]"), tslibs.iNaT
elif "timedelta" in upcast_classes:
return np.dtype("m8[ns]"), np.timedelta64("NaT", "ns")
else:... | def _get_empty_dtype_and_na(join_units):
dtype = upcast_classes["datetimetz"]
return dtype[0], tslibs.NaT
elif "datetime" in upcast_classes:
return np.dtype("M8[ns]"), np.datetime64("NaT", "ns")
elif "timedelta" in upcast_classes:
return np.dtype("m8[ns]"), np.timedelta64("NaT", ... |
def test_merge_multiindex_columns():
expected["id"] = ""
tm.assert_frame_equal(result, expected) | def test_merge_multiindex_columns():
expected["id"] = ""
tm.assert_frame_equal(result, expected)
def test_merge_datetime_upcast_dtype():
# https://github.com/pandas-dev/pandas/issues/31208
df1 = pd.DataFrame({"x": ["a", "b", "c"], "y": ["1", "2", "4"]})
df2 = pd.DataFrame(
{"y": ["1", "2"... |
capfirst = allow_lazy(capfirst, six.text_type)
# Set up regular expressions
re_words = re.compile(r'<.*?>|((?:\w[-\w]*|&.*?;)+)', re.U | re.S)
re_chars = re.compile(r'<.*?>|(.)', re.U | re.S)
re_tag = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S)
re_newlines = re.compile(r'\r\n|\r') # Used in normalize_newlines
... | capfirst = allow_lazy(capfirst, six.text_type)
# Set up regular expressions
re_words = re.compile(r'<.*?>|((?:\w[-\w]*|&.*?;)+)', re.U | re.S)
re_chars = re.compile(r'<.*?>|(.)', re.U | re.S)
re_tag = re.compile(r'<(/)?(\S+?)(?:(\s*/)|\s.*?)?>', re.S)
re_newlines = re.compile(r'\r\n|\r') # Used in normalize_newlines
r... |
class TestUtilsText(SimpleTestCase):
self.assertEqual('<p>I <3 python...</p>',
truncator.words(3, '...', html=True))
def test_wrap(self):
digits = '1234 67 9'
self.assertEqual(text.wrap(digits, 100), '1234 67 9') | class TestUtilsText(SimpleTestCase):
self.assertEqual('<p>I <3 python...</p>',
truncator.words(3, '...', html=True))
re_tag_catastrophic_test = ('</a' + '\t' * 50000) + '//>'
truncator = text.Truncator(re_tag_catastrophic_test)
self.assertEqual(re_tag_catastrophic_test, t... |
from django.db import models
from django.http import Http404
from django.template.engine import Engine
from django.urls import get_mod_func, get_resolver, get_urlconf
from django.utils.decorators import method_decorator
from django.utils.inspect import (
func_accepts_kwargs, func_accepts_var_args, get_func_full_arg... | from django.db import models
from django.http import Http404
from django.template.engine import Engine
from django.urls import get_mod_func, get_resolver, get_urlconf
from django.utils._os import safe_join
from django.utils.decorators import method_decorator
from django.utils.inspect import (
func_accepts_kwargs, f... |
class TemplateDetailView(BaseAdminDocsView):
else:
# This doesn't account for template loaders (#24128).
for index, directory in enumerate(default_engine.dirs):
template_file = Path(directory) / template
if template_file.exists():
with ... | class TemplateDetailView(BaseAdminDocsView):
else:
# This doesn't account for template loaders (#24128).
for index, directory in enumerate(default_engine.dirs):
template_file = Path(safe_join(directory, template))
if template_file.exists():
... |
class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
self.assertContains(response, 'View documentation')
@override_settings(TEMPLATES=[{
'NAME': 'ONE',
'BACKEND': 'django.template.backends.django.DjangoTemplates', | class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
self.assertContains(response, 'View documentation')
@unittest.skipUnless(utils.docutils_is_available, 'no docutils installed.')
class AdminDocViewDefaultEngineOnly(TestDataMixin, AdminDocsTestCase):
def setUp(self):
self.client.force_logi... |
class Axes(_AxesBase):
except ValueError:
pass # Failed to convert to float array; must be color specs.
else:
# If c can be either mapped values or a RGB(A) color, prefer
# the former if shapes match, the latter otherwise.
if c.siz... | class Axes(_AxesBase):
except ValueError:
pass # Failed to convert to float array; must be color specs.
else:
# handle the documented special case of a 2D array with 1
# row which as RGB(A) to broadcast.
if c.shape == (1, 4) or c.s... |
class TestScatter:
c=c_case, edgecolors="black", kwargs={}, xsize=xsize,
get_next_color_func=get_next_color)
def _params(c=None, xsize=2, *, edgecolors=None, **kwargs):
return (c, edgecolors, kwargs if kwargs is not None else {}, xsize) | class TestScatter:
c=c_case, edgecolors="black", kwargs={}, xsize=xsize,
get_next_color_func=get_next_color)
@pytest.mark.style('default')
@check_figures_equal(extensions=["png"])
def test_scatter_single_color_c(self, fig_test, fig_ref):
rgb = [[1, 0.5, 0.05]... |
import stat
from django.http import (
FileResponse, Http404, HttpResponse, HttpResponseNotModified,
HttpResponseRedirect,
)
from django.template import Context, Engine, TemplateDoesNotExist, loader
from django.utils.http import http_date, parse_http_date
from django.utils.translation import gettext as _, gette... | import stat
from django.http import (
FileResponse, Http404, HttpResponse, HttpResponseNotModified,
)
from django.template import Context, Engine, TemplateDoesNotExist, loader
from django.utils._os import safe_join
from django.utils.http import http_date, parse_http_date
from django.utils.translation import gettex... |
def serve(request, path, document_root=None, show_indexes=False):
but if you'd like to override it, you can create a template called
``static/directory_index.html``.
"""
path = posixpath.normpath(path)
path = path.lstrip('/')
newpath = ''
for part in path.split('/'):
if not part:
... | def serve(request, path, document_root=None, show_indexes=False):
but if you'd like to override it, you can create a template called
``static/directory_index.html``.
"""
path = posixpath.normpath(path).lstrip('/')
fullpath = safe_join(document_root, path)
if os.path.isdir(fullpath):
if s... |
class StaticTests(SimpleTestCase):
def test_index(self):
response = self.client.get('/%s/' % self.prefix)
self.assertContains(response, 'Index of /')
class StaticHelperTest(StaticTests): | class StaticTests(SimpleTestCase):
def test_index(self):
response = self.client.get('/%s/' % self.prefix)
self.assertContains(response, 'Index of ./')
class StaticHelperTest(StaticTests): |
def _preprocess_numpy_input(x, data_format, mode):
# Returns
Preprocessed Numpy array.
"""
if mode == 'tf':
x /= 127.5
x -= 1. | def _preprocess_numpy_input(x, data_format, mode):
# Returns
Preprocessed Numpy array.
"""
x = x.astype(K.floatx())
if mode == 'tf':
x /= 127.5
x -= 1. |
from keras.layers import Input, Lambda
def test_preprocess_input():
# Test image batch
x = np.random.uniform(0, 255, (2, 10, 10, 3))
assert utils.preprocess_input(x).shape == x.shape
out1 = utils.preprocess_input(x, 'channels_last')
out2 = utils.preprocess_input(np.transpose(x, (0, 3, 1, 2)),
... | from keras.layers import Input, Lambda
def test_preprocess_input():
# Test image batch with float and int image input
x = np.random.uniform(0, 255, (2, 10, 10, 3))
xint = x.astype('int32')
assert utils.preprocess_input(x).shape == x.shape
assert utils.preprocess_input(xint).shape == xint.shape
... |
import copy
from django import forms
from django.core.exceptions import ValidationError
from django.db.models.deletion import CASCADE
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch | import copy
from django import forms
from django.core.exceptions import ValidationError
from django.core.validators import URLValidator
from django.db.models.deletion import CASCADE
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch |
class AdminEmailInputWidget(forms.EmailInput):
class AdminURLFieldWidget(forms.URLInput):
template_name = 'admin/widgets/url.html'
def __init__(self, attrs=None):
final_attrs = {'class': 'vURLField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminURLFieldWidget, ... | class AdminEmailInputWidget(forms.EmailInput):
class AdminURLFieldWidget(forms.URLInput):
template_name = 'admin/widgets/url.html'
def __init__(self, attrs=None, validator_class=URLValidator):
final_attrs = {'class': 'vURLField'}
if attrs is not None:
final_attrs.update(attrs)
... |
class AdminSplitDateTimeWidgetTest(SimpleTestCase):
class AdminURLWidgetTest(SimpleTestCase):
def test_render(self):
w = widgets.AdminURLFieldWidget()
self.assertHTMLEqual( | class AdminSplitDateTimeWidgetTest(SimpleTestCase):
class AdminURLWidgetTest(SimpleTestCase):
def test_get_context_validates_url(self):
w = widgets.AdminURLFieldWidget()
for invalid in ['', '/not/a/full/url/', 'javascript:alert("Danger XSS!")']:
self.assertFalse(w.get_context('name', i... |
class AdminURLWidgetTest(SimpleTestCase):
VALUE_RE = re.compile('value="([^"]+)"')
TEXT_RE = re.compile('<a[^>]+>([^>]+)</a>')
w = widgets.AdminURLFieldWidget()
output = w.render('test', 'http://example.com/<sometag>some text</sometag>')
self.assertEqual(
HREF_RE.sear... | class AdminURLWidgetTest(SimpleTestCase):
VALUE_RE = re.compile('value="([^"]+)"')
TEXT_RE = re.compile('<a[^>]+>([^>]+)</a>')
w = widgets.AdminURLFieldWidget()
output = w.render('test', 'http://example.com/<sometag>some-text</sometag>')
self.assertEqual(
HREF_RE.sear... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.