aboutsummaryrefslogtreecommitdiffstats
path: root/test/netlib
diff options
context:
space:
mode:
Diffstat (limited to 'test/netlib')
-rw-r--r--test/netlib/test_encoding.py12
-rw-r--r--test/netlib/test_strutils.py5
-rw-r--r--test/netlib/test_tcp.py12
3 files changed, 22 insertions, 7 deletions
diff --git a/test/netlib/test_encoding.py b/test/netlib/test_encoding.py
index a5e81379..08e69ec5 100644
--- a/test/netlib/test_encoding.py
+++ b/test/netlib/test_encoding.py
@@ -21,6 +21,18 @@ def test_gzip():
encoding.decode(b"bogus", "gzip")
+def test_brotli():
+ assert b"string" == encoding.decode(
+ encoding.encode(
+ b"string",
+ "br"
+ ),
+ "br"
+ )
+ with tutils.raises(ValueError):
+ encoding.decode(b"bogus", "br")
+
+
def test_deflate():
assert b"string" == encoding.decode(
encoding.encode(
diff --git a/test/netlib/test_strutils.py b/test/netlib/test_strutils.py
index 7c3eacc6..52299e59 100644
--- a/test/netlib/test_strutils.py
+++ b/test/netlib/test_strutils.py
@@ -48,9 +48,12 @@ def test_bytes_to_escaped_str():
assert strutils.bytes_to_escaped_str(b"\b") == r"\x08"
assert strutils.bytes_to_escaped_str(br"&!?=\)") == r"&!?=\\)"
assert strutils.bytes_to_escaped_str(b'\xc3\xbc') == r"\xc3\xbc"
- assert strutils.bytes_to_escaped_str(b"'") == r"\'"
+ assert strutils.bytes_to_escaped_str(b"'") == r"'"
assert strutils.bytes_to_escaped_str(b'"') == r'"'
+ assert strutils.bytes_to_escaped_str(b"'", escape_single_quotes=True) == r"\'"
+ assert strutils.bytes_to_escaped_str(b'"', escape_single_quotes=True) == r'"'
+
assert strutils.bytes_to_escaped_str(b"\r\n\t") == "\\r\\n\\t"
assert strutils.bytes_to_escaped_str(b"\r\n\t", True) == "\r\n\t"
diff --git a/test/netlib/test_tcp.py b/test/netlib/test_tcp.py
index 273427d5..dc2f4e7e 100644
--- a/test/netlib/test_tcp.py
+++ b/test/netlib/test_tcp.py
@@ -213,7 +213,7 @@ class TestSSLUpstreamCertVerificationWBadServerCert(tservers.ServerTestBase):
# Verification errors should be saved even if connection isn't aborted
# aborted
- assert c.ssl_verification_error is not None
+ assert c.ssl_verification_error
testval = b"echo!\n"
c.wfile.write(testval)
@@ -226,7 +226,7 @@ class TestSSLUpstreamCertVerificationWBadServerCert(tservers.ServerTestBase):
c.convert_to_ssl(verify_options=SSL.VERIFY_NONE)
# Verification errors should be saved even if connection isn't aborted
- assert c.ssl_verification_error is not None
+ assert c.ssl_verification_error
testval = b"echo!\n"
c.wfile.write(testval)
@@ -243,11 +243,11 @@ class TestSSLUpstreamCertVerificationWBadServerCert(tservers.ServerTestBase):
ca_pemfile=tutils.test_data.path("data/verificationcerts/trusted-root.crt")
)
- assert c.ssl_verification_error is not None
+ assert c.ssl_verification_error
# Unknown issuing certificate authority for first certificate
- assert c.ssl_verification_error['errno'] == 18
- assert c.ssl_verification_error['depth'] == 0
+ assert "errno: 18" in str(c.ssl_verification_error)
+ assert "depth: 0" in str(c.ssl_verification_error)
class TestSSLUpstreamCertVerificationWBadHostname(tservers.ServerTestBase):
@@ -276,7 +276,7 @@ class TestSSLUpstreamCertVerificationWBadHostname(tservers.ServerTestBase):
verify_options=SSL.VERIFY_PEER,
ca_pemfile=tutils.test_data.path("data/verificationcerts/trusted-root.crt")
)
- assert c.ssl_verification_error is not None
+ assert c.ssl_verification_error
class TestSSLUpstreamCertVerificationWValidCertChain(tservers.ServerTestBase):