code
stringlengths 26
870k
| docstring
stringlengths 1
65.6k
| func_name
stringlengths 1
194
| language
stringclasses 1
value | repo
stringlengths 8
68
| path
stringlengths 5
182
| url
stringlengths 46
251
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
def test_writeHeadersSanitizesLinearWhitespace(self):
"""
L{HTTPChannel.writeHeaders} removes linear whitespace from the
list of header names and values it receives.
"""
for component in bytesLinearWhitespaceComponents:
transport = StringTransport()
channel = http.HTTPChannel()
channel.makeConnection(transport)
channel.writeHeaders(
version=b"HTTP/1.1",
code=b"200",
reason=b"OK",
headers=[(component, component)])
sanitizedHeaderLine = b": ".join([
sanitizedBytes, sanitizedBytes,
]) + b'\r\n'
self.assertEqual(
transport.value(),
b"\r\n".join([
b"HTTP/1.1 200 OK",
sanitizedHeaderLine,
b'',
])) | L{HTTPChannel.writeHeaders} removes linear whitespace from the
list of header names and values it receives. | test_writeHeadersSanitizesLinearWhitespace | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_http.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_http.py | MIT |
def test_sendHeaderSanitizesLinearWhitespace(self):
"""
L{HTTPClient.sendHeader} replaces linear whitespace in its
header keys and values with a single space.
"""
for component in bytesLinearWhitespaceComponents:
transport = StringTransport()
client = http.HTTPClient()
client.makeConnection(transport)
client.sendHeader(component, component)
self.assertEqual(
transport.value().splitlines(),
[b": ".join([sanitizedBytes, sanitizedBytes])]
) | L{HTTPClient.sendHeader} replaces linear whitespace in its
header keys and values with a single space. | test_sendHeaderSanitizesLinearWhitespace | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_http.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_http.py | MIT |
def test_leadingTextDropping(self):
"""
Make sure that if there's no top-level node lenient-mode won't
drop leading text that's outside of any elements.
"""
s = "Hi orders! <br>Well. <br>"
d = microdom.parseString(s, beExtremelyLenient=True)
self.assertEqual(d.firstChild().toxml(),
'<html>Hi orders! <br />Well. <br /></html>')
byteStream = BytesIO()
d.firstChild().writexml(byteStream, '', '', '', '', {}, '')
self.assertEqual(byteStream.getvalue(),
b'<html>Hi orders! <br />Well. <br /></html>') | Make sure that if there's no top-level node lenient-mode won't
drop leading text that's outside of any elements. | test_leadingTextDropping | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_trailingTextDropping(self):
"""
Ensure that no *trailing* text in a mal-formed
no-top-level-element document(s) will not be dropped.
"""
s = "<br>Hi orders!"
d = microdom.parseString(s, beExtremelyLenient=True)
self.assertEqual(d.firstChild().toxml(),
'<html><br />Hi orders!</html>')
byteStream = BytesIO()
d.firstChild().writexml(byteStream, '', '', '', '', {}, '')
self.assertEqual(byteStream.getvalue(),
b'<html><br />Hi orders!</html>') | Ensure that no *trailing* text in a mal-formed
no-top-level-element document(s) will not be dropped. | test_trailingTextDropping | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_noTags(self):
"""
A string with nothing that looks like a tag at all should just
be parsed as body text.
"""
s = "Hi orders!"
d = microdom.parseString(s, beExtremelyLenient=True)
self.assertEqual(d.firstChild().toxml(),
"<html>Hi orders!</html>") | A string with nothing that looks like a tag at all should just
be parsed as body text. | test_noTags | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_surroundingCrap(self):
"""
If a document is surrounded by non-xml text, the text should
be remain in the XML.
"""
s = "Hi<br> orders!"
d = microdom.parseString(s, beExtremelyLenient=True)
self.assertEqual(d.firstChild().toxml(),
"<html>Hi<br /> orders!</html>") | If a document is surrounded by non-xml text, the text should
be remain in the XML. | test_surroundingCrap | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_lenientParenting(self):
"""
Test that C{parentNode} attributes are set to meaningful values when
we are parsing HTML that lacks a root node.
"""
# Spare the rod, ruin the child.
s = "<br/><br/>"
d = microdom.parseString(s, beExtremelyLenient=1)
self.assertIdentical(d.documentElement,
d.documentElement.firstChild().parentNode) | Test that C{parentNode} attributes are set to meaningful values when
we are parsing HTML that lacks a root node. | test_lenientParenting | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_lenientParentSingle(self):
"""
Test that the C{parentNode} attribute is set to a meaningful value
when we parse an HTML document that has a non-Element root node.
"""
s = "Hello"
d = microdom.parseString(s, beExtremelyLenient=1)
self.assertIdentical(d.documentElement,
d.documentElement.firstChild().parentNode) | Test that the C{parentNode} attribute is set to a meaningful value
when we parse an HTML document that has a non-Element root node. | test_lenientParentSingle | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_replaceNonChild(self):
"""
L{Node.replaceChild} raises L{ValueError} if the node given to be
replaced is not a child of the node C{replaceChild} is called on.
"""
parent = microdom.parseString('<foo />')
orphan = microdom.parseString('<bar />')
replacement = microdom.parseString('<baz />')
self.assertRaises(
ValueError, parent.replaceChild, replacement, orphan) | L{Node.replaceChild} raises L{ValueError} if the node given to be
replaced is not a child of the node C{replaceChild} is called on. | test_replaceNonChild | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_dict(self):
"""
Returns a dictionary which is hashable.
"""
n = microdom.Element("p")
hash(n) | Returns a dictionary which is hashable. | test_dict | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_namespaceDelete(self):
"""
Test that C{toxml} can support xml structures that remove namespaces.
"""
s1 = ('<?xml version="1.0"?><html xmlns="http://www.w3.org/TR/REC-html40">'
'<body xmlns=""></body></html>')
s2 = microdom.parseString(s1).toxml()
self.assertEqual(s1, s2) | Test that C{toxml} can support xml structures that remove namespaces. | test_namespaceDelete | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_namespaceInheritance(self):
"""
Check that unspecified namespace is a thing separate from undefined
namespace. This test added after discovering some weirdness in Lore.
"""
# will only work if childNodes is mutated. not sure why.
child = microdom.Element('ol')
parent = microdom.Element('div', namespace='http://www.w3.org/1999/xhtml')
parent.childNodes = [child]
self.assertEqual(parent.toxml(),
'<div xmlns="http://www.w3.org/1999/xhtml"><ol></ol></div>') | Check that unspecified namespace is a thing separate from undefined
namespace. This test added after discovering some weirdness in Lore. | test_namespaceInheritance | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_prefixedTags(self):
"""
XML elements with a prefixed name as per upper level tag definition
have a start-tag of C{"<prefix:tag>"} and an end-tag of
C{"</prefix:tag>"}.
Refer to U{http://www.w3.org/TR/xml-names/#ns-using} for details.
"""
outerNamespace = "http://example.com/outer"
innerNamespace = "http://example.com/inner"
document = microdom.Document()
# Create the root in one namespace. Microdom will probably make this
# the default namespace.
root = document.createElement("root", namespace=outerNamespace)
# Give the root some prefixes to use.
root.addPrefixes({innerNamespace: "inner"})
# Append a child to the root from the namespace that prefix is bound
# to.
tag = document.createElement("tag", namespace=innerNamespace)
# Give that tag a child too. This way we test rendering of tags with
# children and without children.
child = document.createElement("child", namespace=innerNamespace)
tag.appendChild(child)
root.appendChild(tag)
document.appendChild(root)
# ok, the xml should appear like this
xmlOk = (
'<?xml version="1.0"?>'
'<root xmlns="http://example.com/outer" '
'xmlns:inner="http://example.com/inner">'
'<inner:tag><inner:child></inner:child></inner:tag>'
'</root>')
xmlOut = document.toxml()
self.assertEqual(xmlOut, xmlOk) | XML elements with a prefixed name as per upper level tag definition
have a start-tag of C{"<prefix:tag>"} and an end-tag of
C{"</prefix:tag>"}.
Refer to U{http://www.w3.org/TR/xml-names/#ns-using} for details. | test_prefixedTags | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_prefixPropagation(self):
"""
Children of prefixed tags respect the default namespace at the point
where they are rendered. Specifically, they are not influenced by the
prefix of their parent as that prefix has no bearing on them.
See U{http://www.w3.org/TR/xml-names/#scoping} for details.
To further clarify the matter, the following::
<root xmlns="http://example.com/ns/test">
<mytag xmlns="http://example.com/ns/mytags">
<mysubtag xmlns="http://example.com/ns/mytags">
<element xmlns="http://example.com/ns/test"></element>
</mysubtag>
</mytag>
</root>
Should become this after all the namespace declarations have been
I{moved up}::
<root xmlns="http://example.com/ns/test"
xmlns:mytags="http://example.com/ns/mytags">
<mytags:mytag>
<mytags:mysubtag>
<element></element>
</mytags:mysubtag>
</mytags:mytag>
</root>
"""
outerNamespace = "http://example.com/outer"
innerNamespace = "http://example.com/inner"
document = microdom.Document()
# creates a root element
root = document.createElement("root", namespace=outerNamespace)
document.appendChild(root)
# Create a child with a specific namespace with a prefix bound to it.
root.addPrefixes({innerNamespace: "inner"})
mytag = document.createElement("mytag",namespace=innerNamespace)
root.appendChild(mytag)
# Create a child of that which has the outer namespace.
mysubtag = document.createElement("mysubtag", namespace=outerNamespace)
mytag.appendChild(mysubtag)
xmlOk = (
'<?xml version="1.0"?>'
'<root xmlns="http://example.com/outer" '
'xmlns:inner="http://example.com/inner">'
'<inner:mytag>'
'<mysubtag></mysubtag>'
'</inner:mytag>'
'</root>'
)
xmlOut = document.toxml()
self.assertEqual(xmlOut, xmlOk) | Children of prefixed tags respect the default namespace at the point
where they are rendered. Specifically, they are not influenced by the
prefix of their parent as that prefix has no bearing on them.
See U{http://www.w3.org/TR/xml-names/#scoping} for details.
To further clarify the matter, the following::
<root xmlns="http://example.com/ns/test">
<mytag xmlns="http://example.com/ns/mytags">
<mysubtag xmlns="http://example.com/ns/mytags">
<element xmlns="http://example.com/ns/test"></element>
</mysubtag>
</mytag>
</root>
Should become this after all the namespace declarations have been
I{moved up}::
<root xmlns="http://example.com/ns/test"
xmlns:mytags="http://example.com/ns/mytags">
<mytags:mytag>
<mytags:mysubtag>
<element></element>
</mytags:mysubtag>
</mytags:mytag>
</root> | test_prefixPropagation | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def checkParsed(self, input, expected, beExtremelyLenient=1):
"""
Check that C{input}, when parsed, produces a DOM where the XML
of the document element is equal to C{expected}.
"""
output = microdom.parseString(input,
beExtremelyLenient=beExtremelyLenient)
self.assertEqual(output.documentElement.toxml(), expected) | Check that C{input}, when parsed, produces a DOM where the XML
of the document element is equal to C{expected}. | checkParsed | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_brokenAttributeName(self):
"""
Check that microdom does its best to handle broken attribute names.
The important thing is that it doesn't raise an exception.
"""
input = '<body><h1><div al!\n ign="center">Foo</div></h1></body>'
expected = ('<body><h1><div al="True" ign="center">'
'Foo</div></h1></body>')
self.checkParsed(input, expected) | Check that microdom does its best to handle broken attribute names.
The important thing is that it doesn't raise an exception. | test_brokenAttributeName | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_brokenAttributeValue(self):
"""
Check that microdom encompasses broken attribute values.
"""
input = '<body><h1><div align="cen!\n ter">Foo</div></h1></body>'
expected = '<body><h1><div align="cen!\n ter">Foo</div></h1></body>'
self.checkParsed(input, expected) | Check that microdom encompasses broken attribute values. | test_brokenAttributeValue | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_brokenOpeningTag(self):
"""
Check that microdom does its best to handle broken opening tags.
The important thing is that it doesn't raise an exception.
"""
input = '<body><h1><sp!\n an>Hello World!</span></h1></body>'
expected = '<body><h1><sp an="True">Hello World!</sp></h1></body>'
self.checkParsed(input, expected) | Check that microdom does its best to handle broken opening tags.
The important thing is that it doesn't raise an exception. | test_brokenOpeningTag | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_brokenSelfClosingTag(self):
"""
Check that microdom does its best to handle broken self-closing tags
The important thing is that it doesn't raise an exception.
"""
self.checkParsed('<body><span /!\n></body>',
'<body><span></span></body>')
self.checkParsed('<span!\n />', '<span></span>') | Check that microdom does its best to handle broken self-closing tags
The important thing is that it doesn't raise an exception. | test_brokenSelfClosingTag | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_brokenClosingTag(self):
"""
Check that microdom does its best to handle broken closing tags.
The important thing is that it doesn't raise an exception.
"""
input = '<body><h1><span>Hello World!</sp!\nan></h1></body>'
expected = '<body><h1><span>Hello World!</span></h1></body>'
self.checkParsed(input, expected)
input = '<body><h1><span>Hello World!</!\nspan></h1></body>'
self.checkParsed(input, expected)
input = '<body><h1><span>Hello World!</span!\n></h1></body>'
self.checkParsed(input, expected)
input = '<body><h1><span>Hello World!<!\n/span></h1></body>'
expected = '<body><h1><span>Hello World!<!></!></span></h1></body>'
self.checkParsed(input, expected) | Check that microdom does its best to handle broken closing tags.
The important thing is that it doesn't raise an exception. | test_brokenClosingTag | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_isNodeEqualTo(self):
"""
L{Node.isEqualToNode} returns C{True} if and only if passed a L{Node}
with the same children.
"""
# A node is equal to itself
node = microdom.Node(object())
self.assertTrue(node.isEqualToNode(node))
another = microdom.Node(object())
# Two nodes with no children are equal
self.assertTrue(node.isEqualToNode(another))
node.appendChild(microdom.Node(object()))
# A node with no children is not equal to a node with a child
self.assertFalse(node.isEqualToNode(another))
another.appendChild(microdom.Node(object()))
# A node with a child and no grandchildren is equal to another node
# with a child and no grandchildren.
self.assertTrue(node.isEqualToNode(another))
# A node with a child and a grandchild is not equal to another node
# with a child and no grandchildren.
node.firstChild().appendChild(microdom.Node(object()))
self.assertFalse(node.isEqualToNode(another))
# A node with a child and a grandchild is equal to another node with a
# child and a grandchild.
another.firstChild().appendChild(microdom.Node(object()))
self.assertTrue(node.isEqualToNode(another)) | L{Node.isEqualToNode} returns C{True} if and only if passed a L{Node}
with the same children. | test_isNodeEqualTo | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_validChildInstance(self):
"""
Children of L{Node} instances must also be L{Node} instances.
"""
node = microdom.Node()
child = microdom.Node()
# Node.appendChild() only accepts Node instances.
node.appendChild(child)
self.assertRaises(TypeError, node.appendChild, None)
# Node.insertBefore() only accepts Node instances.
self.assertRaises(TypeError, node.insertBefore, child, None)
self.assertRaises(TypeError, node.insertBefore, None, child)
self.assertRaises(TypeError, node.insertBefore, None, None)
# Node.removeChild() only accepts Node instances.
node.removeChild(child)
self.assertRaises(TypeError, node.removeChild, None)
# Node.replaceChild() only accepts Node instances.
self.assertRaises(TypeError, node.replaceChild, child, None)
self.assertRaises(TypeError, node.replaceChild, None, child)
self.assertRaises(TypeError, node.replaceChild, None, None) | Children of L{Node} instances must also be L{Node} instances. | test_validChildInstance | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_isEqualToNode(self):
"""
L{Document.isEqualToNode} returns C{True} if and only if passed a
L{Document} with the same C{doctype} and C{documentElement}.
"""
# A document is equal to itself
document = microdom.Document()
self.assertTrue(document.isEqualToNode(document))
# A document without a doctype or documentElement is equal to another
# document without a doctype or documentElement.
another = microdom.Document()
self.assertTrue(document.isEqualToNode(another))
# A document with a doctype is not equal to a document without a
# doctype.
document.doctype = self.doctype
self.assertFalse(document.isEqualToNode(another))
# Two documents with the same doctype are equal
another.doctype = self.doctype
self.assertTrue(document.isEqualToNode(another))
# A document with a documentElement is not equal to a document without
# a documentElement
document.appendChild(microdom.Node(object()))
self.assertFalse(document.isEqualToNode(another))
# Two documents with equal documentElements are equal.
another.appendChild(microdom.Node(object()))
self.assertTrue(document.isEqualToNode(another))
# Two documents with documentElements which are not equal are not
# equal.
document.documentElement.appendChild(microdom.Node(object()))
self.assertFalse(document.isEqualToNode(another)) | L{Document.isEqualToNode} returns C{True} if and only if passed a
L{Document} with the same C{doctype} and C{documentElement}. | test_isEqualToNode | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_childRestriction(self):
"""
L{Document.appendChild} raises L{ValueError} if the document already
has a child.
"""
document = microdom.Document()
child = microdom.Node()
another = microdom.Node()
document.appendChild(child)
self.assertRaises(ValueError, document.appendChild, another) | L{Document.appendChild} raises L{ValueError} if the document already
has a child. | test_childRestriction | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_isEqualToNode(self):
"""
L{EntityReference.isEqualToNode} returns C{True} if and only if passed
a L{EntityReference} with the same C{eref}.
"""
self.assertTrue(
microdom.EntityReference('quot').isEqualToNode(
microdom.EntityReference('quot')))
self.assertFalse(
microdom.EntityReference('quot').isEqualToNode(
microdom.EntityReference('apos'))) | L{EntityReference.isEqualToNode} returns C{True} if and only if passed
a L{EntityReference} with the same C{eref}. | test_isEqualToNode | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_isEqualToNode(self):
"""
L{CharacterData.isEqualToNode} returns C{True} if and only if passed a
L{CharacterData} with the same value.
"""
self.assertTrue(
microdom.CharacterData('foo').isEqualToNode(
microdom.CharacterData('foo')))
self.assertFalse(
microdom.CharacterData('foo').isEqualToNode(
microdom.CharacterData('bar'))) | L{CharacterData.isEqualToNode} returns C{True} if and only if passed a
L{CharacterData} with the same value. | test_isEqualToNode | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_isEqualToNode(self):
"""
L{Comment.isEqualToNode} returns C{True} if and only if passed a
L{Comment} with the same value.
"""
self.assertTrue(
microdom.Comment('foo').isEqualToNode(
microdom.Comment('foo')))
self.assertFalse(
microdom.Comment('foo').isEqualToNode(
microdom.Comment('bar'))) | L{Comment.isEqualToNode} returns C{True} if and only if passed a
L{Comment} with the same value. | test_isEqualToNode | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_isEqualToNode(self):
"""
L{Text.isEqualToNode} returns C{True} if and only if passed a L{Text}
which represents the same data.
"""
self.assertTrue(
microdom.Text('foo', raw=True).isEqualToNode(
microdom.Text('foo', raw=True)))
self.assertFalse(
microdom.Text('foo', raw=True).isEqualToNode(
microdom.Text('foo', raw=False)))
self.assertFalse(
microdom.Text('foo', raw=True).isEqualToNode(
microdom.Text('bar', raw=True))) | L{Text.isEqualToNode} returns C{True} if and only if passed a L{Text}
which represents the same data. | test_isEqualToNode | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_isEqualToNode(self):
"""
L{CDATASection.isEqualToNode} returns C{True} if and only if passed a
L{CDATASection} which represents the same data.
"""
self.assertTrue(
microdom.CDATASection('foo').isEqualToNode(
microdom.CDATASection('foo')))
self.assertFalse(
microdom.CDATASection('foo').isEqualToNode(
microdom.CDATASection('bar'))) | L{CDATASection.isEqualToNode} returns C{True} if and only if passed a
L{CDATASection} which represents the same data. | test_isEqualToNode | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def test_isEqualToNode(self):
"""
L{Element.isEqualToNode} returns C{True} if and only if passed a
L{Element} with the same C{nodeName}, C{namespace}, C{childNodes}, and
C{attributes}.
"""
self.assertTrue(
microdom.Element(
'foo', {'a': 'b'}, object(), namespace='bar').isEqualToNode(
microdom.Element(
'foo', {'a': 'b'}, object(), namespace='bar')))
# Elements with different nodeName values do not compare equal.
self.assertFalse(
microdom.Element(
'foo', {'a': 'b'}, object(), namespace='bar').isEqualToNode(
microdom.Element(
'bar', {'a': 'b'}, object(), namespace='bar')))
# Elements with different namespaces do not compare equal.
self.assertFalse(
microdom.Element(
'foo', {'a': 'b'}, object(), namespace='bar').isEqualToNode(
microdom.Element(
'foo', {'a': 'b'}, object(), namespace='baz')))
# Elements with different childNodes do not compare equal.
one = microdom.Element('foo', {'a': 'b'}, object(), namespace='bar')
two = microdom.Element('foo', {'a': 'b'}, object(), namespace='bar')
two.appendChild(microdom.Node(object()))
self.assertFalse(one.isEqualToNode(two))
# Elements with different attributes do not compare equal.
self.assertFalse(
microdom.Element(
'foo', {'a': 'b'}, object(), namespace='bar').isEqualToNode(
microdom.Element(
'foo', {'a': 'c'}, object(), namespace='bar'))) | L{Element.isEqualToNode} returns C{True} if and only if passed a
L{Element} with the same C{nodeName}, C{namespace}, C{childNodes}, and
C{attributes}. | test_isEqualToNode | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_xml.py | MIT |
def _testRender(self, uri, expectedURI):
"""
Check that a request pointing at C{uri} produce a new proxy connection,
with the path of this request pointing at C{expectedURI}.
"""
root = Resource()
reactor = MemoryReactor()
resource = ReverseProxyResource(u"127.0.0.1", 1234, b"/path", reactor)
root.putChild(b'index', resource)
site = Site(root)
transport = StringTransportWithDisconnection()
channel = site.buildProtocol(None)
channel.makeConnection(transport)
# Clear the timeout if the tests failed
self.addCleanup(channel.connectionLost, None)
channel.dataReceived(b"GET " +
uri +
b" HTTP/1.1\r\nAccept: text/html\r\n\r\n")
[(host, port, factory, _timeout, _bind_addr)] = reactor.tcpClients
# Check that one connection has been created, to the good host/port
self.assertEqual(host, u"127.0.0.1")
self.assertEqual(port, 1234)
# Check the factory passed to the connect, and its given path
self.assertIsInstance(factory, ProxyClientFactory)
self.assertEqual(factory.rest, expectedURI)
self.assertEqual(factory.headers[b"host"], b"127.0.0.1:1234") | Check that a request pointing at C{uri} produce a new proxy connection,
with the path of this request pointing at C{expectedURI}. | _testRender | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_render(self):
"""
Test that L{ReverseProxyResource.render} initiates a connection to the
given server with a L{ProxyClientFactory} as parameter.
"""
return self._testRender(b"/index", b"/path") | Test that L{ReverseProxyResource.render} initiates a connection to the
given server with a L{ProxyClientFactory} as parameter. | test_render | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_render_subpage(self):
"""
Test that L{ReverseProxyResource.render} will instantiate a child
resource that will initiate a connection to the given server
requesting the apropiate url subpath.
"""
return self._testRender(b"/index/page1", b"/path/page1") | Test that L{ReverseProxyResource.render} will instantiate a child
resource that will initiate a connection to the given server
requesting the apropiate url subpath. | test_render_subpage | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_renderWithQuery(self):
"""
Test that L{ReverseProxyResource.render} passes query parameters to the
created factory.
"""
return self._testRender(b"/index?foo=bar", b"/path?foo=bar") | Test that L{ReverseProxyResource.render} passes query parameters to the
created factory. | test_renderWithQuery | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_getChild(self):
"""
The L{ReverseProxyResource.getChild} method should return a resource
instance with the same class as the originating resource, forward
port, host, and reactor values, and update the path value with the
value passed.
"""
reactor = MemoryReactor()
resource = ReverseProxyResource(u"127.0.0.1", 1234, b"/path", reactor)
child = resource.getChild(b'foo', None)
# The child should keep the same class
self.assertIsInstance(child, ReverseProxyResource)
self.assertEqual(child.path, b"/path/foo")
self.assertEqual(child.port, 1234)
self.assertEqual(child.host, u"127.0.0.1")
self.assertIdentical(child.reactor, resource.reactor) | The L{ReverseProxyResource.getChild} method should return a resource
instance with the same class as the originating resource, forward
port, host, and reactor values, and update the path value with the
value passed. | test_getChild | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_getChildWithSpecial(self):
"""
The L{ReverseProxyResource} return by C{getChild} has a path which has
already been quoted.
"""
resource = ReverseProxyResource(u"127.0.0.1", 1234, b"/path")
child = resource.getChild(b' /%', None)
self.assertEqual(child.path, b"/path/%20%2F%25") | The L{ReverseProxyResource} return by C{getChild} has a path which has
already been quoted. | test_getChildWithSpecial | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def __init__(self, transport):
"""
Hold a reference to the transport.
"""
self.transport = transport
self.lostReason = None | Hold a reference to the transport. | __init__ | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def connectionLost(self, reason):
"""
Keep track of the connection lost reason.
"""
self.lostReason = reason | Keep track of the connection lost reason. | connectionLost | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def getPeer(self):
"""
Get peer information from the transport.
"""
return self.transport.getPeer() | Get peer information from the transport. | getPeer | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def getHost(self):
"""
Get host information from the transport.
"""
return self.transport.getHost() | Get host information from the transport. | getHost | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def _parseOutHeaders(self, content):
"""
Parse the headers out of some web content.
@param content: Bytes received from a web server.
@return: A tuple of (requestLine, headers, body). C{headers} is a dict
of headers, C{requestLine} is the first line (e.g. "POST /foo ...")
and C{body} is whatever is left.
"""
headers, body = content.split(b'\r\n\r\n')
headers = headers.split(b'\r\n')
requestLine = headers.pop(0)
return (
requestLine, dict(header.split(b': ') for header in headers), body) | Parse the headers out of some web content.
@param content: Bytes received from a web server.
@return: A tuple of (requestLine, headers, body). C{headers} is a dict
of headers, C{requestLine} is the first line (e.g. "POST /foo ...")
and C{body} is whatever is left. | _parseOutHeaders | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def makeRequest(self, path):
"""
Make a dummy request object for the URL path.
@param path: A URL path, beginning with a slash.
@return: A L{DummyRequest}.
"""
return DummyRequest(path) | Make a dummy request object for the URL path.
@param path: A URL path, beginning with a slash.
@return: A L{DummyRequest}. | makeRequest | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def makeProxyClient(self, request, method=b"GET", headers=None,
requestBody=b""):
"""
Make a L{ProxyClient} object used for testing.
@param request: The request to use.
@param method: The HTTP method to use, GET by default.
@param headers: The HTTP headers to use expressed as a dict. If not
provided, defaults to {'accept': 'text/html'}.
@param requestBody: The body of the request. Defaults to the empty
string.
@return: A L{ProxyClient}
"""
if headers is None:
headers = {b"accept": b"text/html"}
path = b'/' + request.postpath
return ProxyClient(
method, path, b'HTTP/1.0', headers, requestBody, request) | Make a L{ProxyClient} object used for testing.
@param request: The request to use.
@param method: The HTTP method to use, GET by default.
@param headers: The HTTP headers to use expressed as a dict. If not
provided, defaults to {'accept': 'text/html'}.
@param requestBody: The body of the request. Defaults to the empty
string.
@return: A L{ProxyClient} | makeProxyClient | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def connectProxy(self, proxyClient):
"""
Connect a proxy client to a L{StringTransportWithDisconnection}.
@param proxyClient: A L{ProxyClient}.
@return: The L{StringTransportWithDisconnection}.
"""
clientTransport = StringTransportWithDisconnection()
clientTransport.protocol = proxyClient
proxyClient.makeConnection(clientTransport)
return clientTransport | Connect a proxy client to a L{StringTransportWithDisconnection}.
@param proxyClient: A L{ProxyClient}.
@return: The L{StringTransportWithDisconnection}. | connectProxy | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def assertForwardsHeaders(self, proxyClient, requestLine, headers):
"""
Assert that C{proxyClient} sends C{headers} when it connects.
@param proxyClient: A L{ProxyClient}.
@param requestLine: The request line we expect to be sent.
@param headers: A dict of headers we expect to be sent.
@return: If the assertion is successful, return the request body as
bytes.
"""
self.connectProxy(proxyClient)
requestContent = proxyClient.transport.value()
receivedLine, receivedHeaders, body = self._parseOutHeaders(
requestContent)
self.assertEqual(receivedLine, requestLine)
self.assertEqual(receivedHeaders, headers)
return body | Assert that C{proxyClient} sends C{headers} when it connects.
@param proxyClient: A L{ProxyClient}.
@param requestLine: The request line we expect to be sent.
@param headers: A dict of headers we expect to be sent.
@return: If the assertion is successful, return the request body as
bytes. | assertForwardsHeaders | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def assertForwardsResponse(self, request, code, message, headers, body):
"""
Assert that C{request} has forwarded a response from the server.
@param request: A L{DummyRequest}.
@param code: The expected HTTP response code.
@param message: The expected HTTP message.
@param headers: The expected HTTP headers.
@param body: The expected response body.
"""
self.assertEqual(request.responseCode, code)
self.assertEqual(request.responseMessage, message)
receivedHeaders = list(request.responseHeaders.getAllRawHeaders())
receivedHeaders.sort()
expectedHeaders = headers[:]
expectedHeaders.sort()
self.assertEqual(receivedHeaders, expectedHeaders)
self.assertEqual(b''.join(request.written), body) | Assert that C{request} has forwarded a response from the server.
@param request: A L{DummyRequest}.
@param code: The expected HTTP response code.
@param message: The expected HTTP message.
@param headers: The expected HTTP headers.
@param body: The expected response body. | assertForwardsResponse | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def _testDataForward(self, code, message, headers, body, method=b"GET",
requestBody=b"", loseConnection=True):
"""
Build a fake proxy connection, and send C{data} over it, checking that
it's forwarded to the originating request.
"""
request = self.makeRequest(b'foo')
client = self.makeProxyClient(
request, method, {b'accept': b'text/html'}, requestBody)
receivedBody = self.assertForwardsHeaders(
client, method + b' /foo HTTP/1.0',
{b'connection': b'close', b'accept': b'text/html'})
self.assertEqual(receivedBody, requestBody)
# Fake an answer
client.dataReceived(
self.makeResponseBytes(code, message, headers, body))
# Check that the response data has been forwarded back to the original
# requester.
self.assertForwardsResponse(request, code, message, headers, body)
# Check that when the response is done, the request is finished.
if loseConnection:
client.transport.loseConnection()
# Even if we didn't call loseConnection, the transport should be
# disconnected. This lets us not rely on the server to close our
# sockets for us.
self.assertFalse(client.transport.connected)
self.assertEqual(request.finished, 1) | Build a fake proxy connection, and send C{data} over it, checking that
it's forwarded to the originating request. | _testDataForward | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_forward(self):
"""
When connected to the server, L{ProxyClient} should send the saved
request, with modifications of the headers, and then forward the result
to the parent request.
"""
return self._testDataForward(
200, b"OK", [(b"Foo", [b"bar", b"baz"])], b"Some data\r\n") | When connected to the server, L{ProxyClient} should send the saved
request, with modifications of the headers, and then forward the result
to the parent request. | test_forward | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_postData(self):
"""
Try to post content in the request, and check that the proxy client
forward the body of the request.
"""
return self._testDataForward(
200, b"OK", [(b"Foo", [b"bar"])], b"Some data\r\n", b"POST", b"Some content") | Try to post content in the request, and check that the proxy client
forward the body of the request. | test_postData | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_statusWithMessage(self):
"""
If the response contains a status with a message, it should be
forwarded to the parent request with all the information.
"""
return self._testDataForward(
404, b"Not Found", [], b"") | If the response contains a status with a message, it should be
forwarded to the parent request with all the information. | test_statusWithMessage | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_contentLength(self):
"""
If the response contains a I{Content-Length} header, the inbound
request object should still only have C{finish} called on it once.
"""
data = b"foo bar baz"
return self._testDataForward(
200,
b"OK",
[(b"Content-Length", [str(len(data)).encode('ascii')])],
data) | If the response contains a I{Content-Length} header, the inbound
request object should still only have C{finish} called on it once. | test_contentLength | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_losesConnection(self):
"""
If the response contains a I{Content-Length} header, the outgoing
connection is closed when all response body data has been received.
"""
data = b"foo bar baz"
return self._testDataForward(
200,
b"OK",
[(b"Content-Length", [str(len(data)).encode('ascii')])],
data,
loseConnection=False) | If the response contains a I{Content-Length} header, the outgoing
connection is closed when all response body data has been received. | test_losesConnection | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_headersCleanups(self):
"""
The headers given at initialization should be modified:
B{proxy-connection} should be removed if present, and B{connection}
should be added.
"""
client = ProxyClient(b'GET', b'/foo', b'HTTP/1.0',
{b"accept": b"text/html", b"proxy-connection": b"foo"}, b'', None)
self.assertEqual(client.headers,
{b"accept": b"text/html", b"connection": b"close"}) | The headers given at initialization should be modified:
B{proxy-connection} should be removed if present, and B{connection}
should be added. | test_headersCleanups | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_keepaliveNotForwarded(self):
"""
The proxy doesn't really know what to do with keepalive things from
the remote server, so we stomp over any keepalive header we get from
the client.
"""
headers = {
b"accept": b"text/html",
b'keep-alive': b'300',
b'connection': b'keep-alive',
}
expectedHeaders = headers.copy()
expectedHeaders[b'connection'] = b'close'
del expectedHeaders[b'keep-alive']
client = ProxyClient(b'GET', b'/foo', b'HTTP/1.0', headers, b'', None)
self.assertForwardsHeaders(
client, b'GET /foo HTTP/1.0', expectedHeaders) | The proxy doesn't really know what to do with keepalive things from
the remote server, so we stomp over any keepalive header we get from
the client. | test_keepaliveNotForwarded | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_defaultHeadersOverridden(self):
"""
L{server.Request} within the proxy sets certain response headers by
default. When we get these headers back from the remote server, the
defaults are overridden rather than simply appended.
"""
request = self.makeRequest(b'foo')
request.responseHeaders.setRawHeaders(b'server', [b'old-bar'])
request.responseHeaders.setRawHeaders(b'date', [b'old-baz'])
request.responseHeaders.setRawHeaders(b'content-type', [b"old/qux"])
client = self.makeProxyClient(request, headers={b'accept': b'text/html'})
self.connectProxy(client)
headers = {
b'Server': [b'bar'],
b'Date': [b'2010-01-01'],
b'Content-Type': [b'application/x-baz'],
}
client.dataReceived(
self.makeResponseBytes(200, b"OK", headers.items(), b''))
self.assertForwardsResponse(
request, 200, b'OK', list(headers.items()), b'') | L{server.Request} within the proxy sets certain response headers by
default. When we get these headers back from the remote server, the
defaults are overridden rather than simply appended. | test_defaultHeadersOverridden | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_connectionFailed(self):
"""
Check that L{ProxyClientFactory.clientConnectionFailed} produces
a B{501} response to the parent request.
"""
request = DummyRequest([b'foo'])
factory = ProxyClientFactory(b'GET', b'/foo', b'HTTP/1.0',
{b"accept": b"text/html"}, '', request)
factory.clientConnectionFailed(None, None)
self.assertEqual(request.responseCode, 501)
self.assertEqual(request.responseMessage, b"Gateway error")
self.assertEqual(
list(request.responseHeaders.getAllRawHeaders()),
[(b"Content-Type", [b"text/html"])])
self.assertEqual(
b''.join(request.written),
b"<H1>Could not connect</H1>")
self.assertEqual(request.finished, 1) | Check that L{ProxyClientFactory.clientConnectionFailed} produces
a B{501} response to the parent request. | test_connectionFailed | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_buildProtocol(self):
"""
L{ProxyClientFactory.buildProtocol} should produce a L{ProxyClient}
with the same values of attributes (with updates on the headers).
"""
factory = ProxyClientFactory(b'GET', b'/foo', b'HTTP/1.0',
{b"accept": b"text/html"}, b'Some data',
None)
proto = factory.buildProtocol(None)
self.assertIsInstance(proto, ProxyClient)
self.assertEqual(proto.command, b'GET')
self.assertEqual(proto.rest, b'/foo')
self.assertEqual(proto.data, b'Some data')
self.assertEqual(proto.headers,
{b"accept": b"text/html", b"connection": b"close"}) | L{ProxyClientFactory.buildProtocol} should produce a L{ProxyClient}
with the same values of attributes (with updates on the headers). | test_buildProtocol | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def _testProcess(self, uri, expectedURI, method=b"GET", data=b""):
"""
Build a request pointing at C{uri}, and check that a proxied request
is created, pointing a C{expectedURI}.
"""
transport = StringTransportWithDisconnection()
channel = DummyChannel(transport)
reactor = MemoryReactor()
request = ProxyRequest(channel, False, reactor)
request.gotLength(len(data))
request.handleContentChunk(data)
request.requestReceived(method, b'http://example.com' + uri,
b'HTTP/1.0')
self.assertEqual(len(reactor.tcpClients), 1)
self.assertEqual(reactor.tcpClients[0][0], u"example.com")
self.assertEqual(reactor.tcpClients[0][1], 80)
factory = reactor.tcpClients[0][2]
self.assertIsInstance(factory, ProxyClientFactory)
self.assertEqual(factory.command, method)
self.assertEqual(factory.version, b'HTTP/1.0')
self.assertEqual(factory.headers, {b'host': b'example.com'})
self.assertEqual(factory.data, data)
self.assertEqual(factory.rest, expectedURI)
self.assertEqual(factory.father, request) | Build a request pointing at C{uri}, and check that a proxied request
is created, pointing a C{expectedURI}. | _testProcess | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_process(self):
"""
L{ProxyRequest.process} should create a connection to the given server,
with a L{ProxyClientFactory} as connection factory, with the correct
parameters:
- forward comment, version and data values
- update headers with the B{host} value
- remove the host from the URL
- pass the request as parent request
"""
return self._testProcess(b"/foo/bar", b"/foo/bar") | L{ProxyRequest.process} should create a connection to the given server,
with a L{ProxyClientFactory} as connection factory, with the correct
parameters:
- forward comment, version and data values
- update headers with the B{host} value
- remove the host from the URL
- pass the request as parent request | test_process | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_processWithoutTrailingSlash(self):
"""
If the incoming request doesn't contain a slash,
L{ProxyRequest.process} should add one when instantiating
L{ProxyClientFactory}.
"""
return self._testProcess(b"", b"/") | If the incoming request doesn't contain a slash,
L{ProxyRequest.process} should add one when instantiating
L{ProxyClientFactory}. | test_processWithoutTrailingSlash | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_processWithData(self):
"""
L{ProxyRequest.process} should be able to retrieve request body and
to forward it.
"""
return self._testProcess(
b"/foo/bar", b"/foo/bar", b"POST", b"Some content") | L{ProxyRequest.process} should be able to retrieve request body and
to forward it. | test_processWithData | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_processWithPort(self):
"""
Check that L{ProxyRequest.process} correctly parse port in the incoming
URL, and create an outgoing connection with this port.
"""
transport = StringTransportWithDisconnection()
channel = DummyChannel(transport)
reactor = MemoryReactor()
request = ProxyRequest(channel, False, reactor)
request.gotLength(0)
request.requestReceived(b'GET', b'http://example.com:1234/foo/bar',
b'HTTP/1.0')
# That should create one connection, with the port parsed from the URL
self.assertEqual(len(reactor.tcpClients), 1)
self.assertEqual(reactor.tcpClients[0][0], u"example.com")
self.assertEqual(reactor.tcpClients[0][1], 1234) | Check that L{ProxyRequest.process} correctly parse port in the incoming
URL, and create an outgoing connection with this port. | test_processWithPort | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def test_process(self):
"""
L{ReverseProxyRequest.process} should create a connection to its
factory host/port, using a L{ProxyClientFactory} instantiated with the
correct parameters, and particularly set the B{host} header to the
factory host.
"""
transport = StringTransportWithDisconnection()
channel = DummyChannel(transport)
reactor = MemoryReactor()
request = ReverseProxyRequest(channel, False, reactor)
request.factory = DummyFactory(u"example.com", 1234)
request.gotLength(0)
request.requestReceived(b'GET', b'/foo/bar', b'HTTP/1.0')
# Check that one connection has been created, to the good host/port
self.assertEqual(len(reactor.tcpClients), 1)
self.assertEqual(reactor.tcpClients[0][0], u"example.com")
self.assertEqual(reactor.tcpClients[0][1], 1234)
# Check the factory passed to the connect, and its headers
factory = reactor.tcpClients[0][2]
self.assertIsInstance(factory, ProxyClientFactory)
self.assertEqual(factory.headers, {b'host': b'example.com'}) | L{ReverseProxyRequest.process} should create a connection to its
factory host/port, using a L{ProxyClientFactory} instantiated with the
correct parameters, and particularly set the B{host} header to the
factory host. | test_process | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py | MIT |
def assertWrapperExceptionTypes(self, deferred, mainType, reasonTypes):
"""
Assert that the given L{Deferred} fails with the exception given by
C{mainType} and that the exceptions wrapped by the instance of C{mainType}
it fails with match the list of exception types given by C{reasonTypes}.
This is a helper for testing failures of exceptions which subclass
L{_newclient._WrapperException}.
@param self: A L{TestCase} instance which will be used to make the
assertions.
@param deferred: The L{Deferred} which is expected to fail with
C{mainType}.
@param mainType: A L{_newclient._WrapperException} subclass which will be
trapped on C{deferred}.
@param reasonTypes: A sequence of exception types which will be trapped on
the resulting C{mainType} exception instance's C{reasons} sequence.
@return: A L{Deferred} which fires with the C{mainType} instance
C{deferred} fails with, or which fails somehow.
"""
def cbFailed(err):
for reason, type in zip(err.reasons, reasonTypes):
reason.trap(type)
self.assertEqual(len(err.reasons), len(reasonTypes),
"len(%s) != len(%s)" % (err.reasons, reasonTypes))
return err
d = self.assertFailure(deferred, mainType)
d.addCallback(cbFailed)
return d | Assert that the given L{Deferred} fails with the exception given by
C{mainType} and that the exceptions wrapped by the instance of C{mainType}
it fails with match the list of exception types given by C{reasonTypes}.
This is a helper for testing failures of exceptions which subclass
L{_newclient._WrapperException}.
@param self: A L{TestCase} instance which will be used to make the
assertions.
@param deferred: The L{Deferred} which is expected to fail with
C{mainType}.
@param mainType: A L{_newclient._WrapperException} subclass which will be
trapped on C{deferred}.
@param reasonTypes: A sequence of exception types which will be trapped on
the resulting C{mainType} exception instance's C{reasons} sequence.
@return: A L{Deferred} which fires with the C{mainType} instance
C{deferred} fails with, or which fails somehow. | assertWrapperExceptionTypes | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def assertResponseFailed(self, deferred, reasonTypes):
"""
A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType}
of L{ResponseFailed}.
"""
return assertWrapperExceptionTypes(self, deferred, ResponseFailed, reasonTypes) | A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType}
of L{ResponseFailed}. | assertResponseFailed | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def assertRequestGenerationFailed(self, deferred, reasonTypes):
"""
A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType}
of L{RequestGenerationFailed}.
"""
return assertWrapperExceptionTypes(self, deferred, RequestGenerationFailed, reasonTypes) | A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType}
of L{RequestGenerationFailed}. | assertRequestGenerationFailed | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def assertRequestTransmissionFailed(self, deferred, reasonTypes):
"""
A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType}
of L{RequestTransmissionFailed}.
"""
return assertWrapperExceptionTypes(self, deferred, RequestTransmissionFailed, reasonTypes) | A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType}
of L{RequestTransmissionFailed}. | assertRequestTransmissionFailed | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def justTransportResponse(transport):
"""
Helper function for creating a Response which uses the given transport.
All of the other parameters to L{Response.__init__} are filled with
arbitrary values. Only use this method if you don't care about any of
them.
"""
return Response((b'HTTP', 1, 1), 200, b'OK', _boringHeaders, transport) | Helper function for creating a Response which uses the given transport.
All of the other parameters to L{Response.__init__} are filled with
arbitrary values. Only use this method if you don't care about any of
them. | justTransportResponse | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_functionCalledByState(self):
"""
A method defined with L{makeStatefulDispatcher} invokes a second
method based on the current state of the object.
"""
class Foo:
_state = 'A'
def bar(self):
pass
bar = makeStatefulDispatcher('quux', bar)
def _quux_A(self):
return 'a'
def _quux_B(self):
return 'b'
stateful = Foo()
self.assertEqual(stateful.bar(), 'a')
stateful._state = 'B'
self.assertEqual(stateful.bar(), 'b')
stateful._state = 'C'
self.assertRaises(RuntimeError, stateful.bar) | A method defined with L{makeStatefulDispatcher} invokes a second
method based on the current state of the object. | test_functionCalledByState | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_statusCallback(self):
"""
L{HTTPParser} calls its C{statusReceived} method when it receives a
status line.
"""
status = []
protocol = HTTPParser()
protocol.statusReceived = status.append
protocol.makeConnection(StringTransport())
self.assertEqual(protocol.state, STATUS)
protocol.dataReceived(b'HTTP/1.1 200 OK' + self.sep)
self.assertEqual(status, [b'HTTP/1.1 200 OK'])
self.assertEqual(protocol.state, HEADER) | L{HTTPParser} calls its C{statusReceived} method when it receives a
status line. | test_statusCallback | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_headerCallback(self):
"""
L{HTTPParser} calls its C{headerReceived} method when it receives a
header.
"""
header, protocol = self._headerTestSetup()
protocol.dataReceived(b'X-Foo:bar' + self.sep)
# Cannot tell it's not a continue header until the next line arrives
# and is not a continuation
protocol.dataReceived(self.sep)
self.assertEqual(header, {b'X-Foo': b'bar'})
self.assertEqual(protocol.state, BODY) | L{HTTPParser} calls its C{headerReceived} method when it receives a
header. | test_headerCallback | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_continuedHeaderCallback(self):
"""
If a header is split over multiple lines, L{HTTPParser} calls
C{headerReceived} with the entire value once it is received.
"""
header, protocol = self._headerTestSetup()
protocol.dataReceived(b'X-Foo: bar' + self.sep)
protocol.dataReceived(b' baz' + self.sep)
protocol.dataReceived(b'\tquux' + self.sep)
protocol.dataReceived(self.sep)
self.assertEqual(header, {b'X-Foo': b'bar baz\tquux'})
self.assertEqual(protocol.state, BODY) | If a header is split over multiple lines, L{HTTPParser} calls
C{headerReceived} with the entire value once it is received. | test_continuedHeaderCallback | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_fieldContentWhitespace(self):
"""
Leading and trailing linear whitespace is stripped from the header
value passed to the C{headerReceived} callback.
"""
header, protocol = self._headerTestSetup()
value = self.sep.join([b' \t ', b' bar \t', b' \t', b''])
protocol.dataReceived(b'X-Bar:' + value)
protocol.dataReceived(b'X-Foo:' + value)
protocol.dataReceived(self.sep)
self.assertEqual(header, {b'X-Foo': b'bar',
b'X-Bar': b'bar'}) | Leading and trailing linear whitespace is stripped from the header
value passed to the C{headerReceived} callback. | test_fieldContentWhitespace | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_allHeadersCallback(self):
"""
After the last header is received, L{HTTPParser} calls
C{allHeadersReceived}.
"""
called = []
header, protocol = self._headerTestSetup()
def allHeadersReceived():
called.append(protocol.state)
protocol.state = STATUS
protocol.allHeadersReceived = allHeadersReceived
protocol.dataReceived(self.sep)
self.assertEqual(called, [HEADER])
self.assertEqual(protocol.state, STATUS) | After the last header is received, L{HTTPParser} calls
C{allHeadersReceived}. | test_allHeadersCallback | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_noHeaderCallback(self):
"""
If there are no headers in the message, L{HTTPParser} does not call
C{headerReceived}.
"""
header, protocol = self._headerTestSetup()
protocol.dataReceived(self.sep)
self.assertEqual(header, {})
self.assertEqual(protocol.state, BODY) | If there are no headers in the message, L{HTTPParser} does not call
C{headerReceived}. | test_noHeaderCallback | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_headersSavedOnResponse(self):
"""
All headers received by L{HTTPParser} are added to
L{HTTPParser.headers}.
"""
protocol = HTTPParser()
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK' + self.sep)
protocol.dataReceived(b'X-Foo: bar' + self.sep)
protocol.dataReceived(b'X-Foo: baz' + self.sep)
protocol.dataReceived(self.sep)
expected = [(b'X-Foo', [b'bar', b'baz'])]
self.assertEqual(expected, list(protocol.headers.getAllRawHeaders())) | All headers received by L{HTTPParser} are added to
L{HTTPParser.headers}. | test_headersSavedOnResponse | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_connectionControlHeaders(self):
"""
L{HTTPParser.isConnectionControlHeader} returns C{True} for headers
which are always connection control headers (similar to "hop-by-hop"
headers from RFC 2616 section 13.5.1) and C{False} for other headers.
"""
protocol = HTTPParser()
connHeaderNames = [
b'content-length', b'connection', b'keep-alive', b'te', b'trailers',
b'transfer-encoding', b'upgrade', b'proxy-connection']
for header in connHeaderNames:
self.assertTrue(
protocol.isConnectionControlHeader(header),
"Expecting %r to be a connection control header, but "
"wasn't" % (header,))
self.assertFalse(
protocol.isConnectionControlHeader(b"date"),
"Expecting the arbitrarily selected 'date' header to not be "
"a connection control header, but was.") | L{HTTPParser.isConnectionControlHeader} returns C{True} for headers
which are always connection control headers (similar to "hop-by-hop"
headers from RFC 2616 section 13.5.1) and C{False} for other headers. | test_connectionControlHeaders | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_switchToBodyMode(self):
"""
L{HTTPParser.switchToBodyMode} raises L{RuntimeError} if called more
than once.
"""
protocol = HTTPParser()
protocol.makeConnection(StringTransport())
protocol.switchToBodyMode(object())
self.assertRaises(RuntimeError, protocol.switchToBodyMode, object()) | L{HTTPParser.switchToBodyMode} raises L{RuntimeError} if called more
than once. | test_switchToBodyMode | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_parseVersion(self):
"""
L{HTTPClientParser.parseVersion} parses a status line into its three
components.
"""
protocol = HTTPClientParser(None, None)
self.assertEqual(
protocol.parseVersion(b'CANDY/7.2'),
(b'CANDY', 7, 2)) | L{HTTPClientParser.parseVersion} parses a status line into its three
components. | test_parseVersion | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_parseBadVersion(self):
"""
L{HTTPClientParser.parseVersion} raises L{ValueError} when passed an
unparsable version.
"""
protocol = HTTPClientParser(None, None)
e = BadResponseVersion
f = protocol.parseVersion
def checkParsing(s):
exc = self.assertRaises(e, f, s)
self.assertEqual(exc.data, s)
checkParsing(b'foo')
checkParsing(b'foo/bar/baz')
checkParsing(b'foo/')
checkParsing(b'foo/..')
checkParsing(b'foo/a.b')
checkParsing(b'foo/-1.-1') | L{HTTPClientParser.parseVersion} raises L{ValueError} when passed an
unparsable version. | test_parseBadVersion | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_responseStatusParsing(self):
"""
L{HTTPClientParser.statusReceived} parses the version, code, and phrase
from the status line and stores them on the response object.
"""
request = Request(b'GET', b'/', _boringHeaders, None)
protocol = HTTPClientParser(request, None)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
self.assertEqual(protocol.response.version, (b'HTTP', 1, 1))
self.assertEqual(protocol.response.code, 200)
self.assertEqual(protocol.response.phrase, b'OK') | L{HTTPClientParser.statusReceived} parses the version, code, and phrase
from the status line and stores them on the response object. | test_responseStatusParsing | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_responseStatusWithoutPhrase(self):
"""
L{HTTPClientParser.statusReceived} can parse a status line without a
phrase (though such lines are a violation of RFC 7230, section 3.1.2;
nevertheless some broken servers omit the phrase).
"""
request = Request(b'GET', b'/', _boringHeaders, None)
protocol = HTTPClientParser(request, None)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200\r\n')
self.assertEqual(protocol.response.version, (b'HTTP', 1, 1))
self.assertEqual(protocol.response.code, 200)
self.assertEqual(protocol.response.phrase, b'') | L{HTTPClientParser.statusReceived} can parse a status line without a
phrase (though such lines are a violation of RFC 7230, section 3.1.2;
nevertheless some broken servers omit the phrase). | test_responseStatusWithoutPhrase | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_badResponseStatus(self):
"""
L{HTTPClientParser.statusReceived} raises L{ParseError} if it is called
with a status line which cannot be parsed.
"""
protocol = HTTPClientParser(None, None)
def checkParsing(s):
exc = self.assertRaises(ParseError, protocol.statusReceived, s)
self.assertEqual(exc.data, s)
# If there are fewer than two whitespace-delimited parts to the status
# line, it is not valid and cannot be parsed.
checkParsing(b'foo')
# If the response code is not an integer, the status line is not valid
# and cannot be parsed.
checkParsing(b'HTTP/1.1 bar OK') | L{HTTPClientParser.statusReceived} raises L{ParseError} if it is called
with a status line which cannot be parsed. | test_badResponseStatus | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def _noBodyTest(self, request, status, response):
"""
Assert that L{HTTPClientParser} parses the given C{response} to
C{request}, resulting in a response with no body and no extra bytes and
leaving the transport in the producing state.
@param request: A L{Request} instance which might have caused a server
to return the given response.
@param status: A string giving the status line of the response to be
parsed.
@param response: A string giving the response to be parsed.
@return: A C{dict} of headers from the response.
"""
header = {}
finished = []
body = []
bodyDataFinished = []
protocol = HTTPClientParser(request, finished.append)
protocol.headerReceived = header.__setitem__
transport = StringTransport()
protocol.makeConnection(transport)
# Deliver just the status to initialize the response object so we can
# monkey-patch it to observe progress of the response parser.
protocol.dataReceived(status)
protocol.response._bodyDataReceived = body.append
protocol.response._bodyDataFinished = (
lambda: bodyDataFinished.append(True))
protocol.dataReceived(response)
self.assertEqual(transport.producerState, u'producing')
self.assertEqual(protocol.state, DONE)
self.assertEqual(body, [])
self.assertEqual(finished, [b''])
self.assertEqual(bodyDataFinished, [True])
self.assertEqual(protocol.response.length, 0)
return header | Assert that L{HTTPClientParser} parses the given C{response} to
C{request}, resulting in a response with no body and no extra bytes and
leaving the transport in the producing state.
@param request: A L{Request} instance which might have caused a server
to return the given response.
@param status: A string giving the status line of the response to be
parsed.
@param response: A string giving the response to be parsed.
@return: A C{dict} of headers from the response. | _noBodyTest | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_headResponse(self):
"""
If the response is to a HEAD request, no body is expected, the body
callback is not invoked, and the I{Content-Length} header is passed to
the header callback.
"""
request = Request(b'HEAD', b'/', _boringHeaders, None)
status = b'HTTP/1.1 200 OK\r\n'
response = (
b'Content-Length: 10\r\n'
b'\r\n')
header = self._noBodyTest(request, status, response)
self.assertEqual(header, {b'Content-Length': b'10'}) | If the response is to a HEAD request, no body is expected, the body
callback is not invoked, and the I{Content-Length} header is passed to
the header callback. | test_headResponse | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_noContentResponse(self):
"""
If the response code is I{NO CONTENT} (204), no body is expected and
the body callback is not invoked.
"""
request = Request(b'GET', b'/', _boringHeaders, None)
status = b'HTTP/1.1 204 NO CONTENT\r\n'
response = b'\r\n'
self._noBodyTest(request, status, response) | If the response code is I{NO CONTENT} (204), no body is expected and
the body callback is not invoked. | test_noContentResponse | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_notModifiedResponse(self):
"""
If the response code is I{NOT MODIFIED} (304), no body is expected and
the body callback is not invoked.
"""
request = Request(b'GET', b'/', _boringHeaders, None)
status = b'HTTP/1.1 304 NOT MODIFIED\r\n'
response = b'\r\n'
self._noBodyTest(request, status, response) | If the response code is I{NOT MODIFIED} (304), no body is expected and
the body callback is not invoked. | test_notModifiedResponse | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_responseHeaders(self):
"""
The response headers are added to the response object's C{headers}
L{Headers} instance.
"""
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None),
lambda rest: None)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
protocol.dataReceived(b'X-Foo: bar\r\n')
protocol.dataReceived(b'\r\n')
self.assertEqual(
protocol.connHeaders,
Headers({}))
self.assertEqual(
protocol.response.headers,
Headers({b'x-foo': [b'bar']}))
self.assertIdentical(protocol.response.length, UNKNOWN_LENGTH) | The response headers are added to the response object's C{headers}
L{Headers} instance. | test_responseHeaders | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_responseHeadersMultiline(self):
"""
The multi-line response headers are folded and added to the response
object's C{headers} L{Headers} instance.
"""
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None),
lambda rest: None)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
protocol.dataReceived(b'X-Multiline: a\r\n')
protocol.dataReceived(b' b\r\n')
protocol.dataReceived(b'\r\n')
self.assertEqual(
protocol.connHeaders,
Headers({}))
self.assertEqual(
protocol.response.headers,
Headers({b'x-multiline': [b'a b']}))
self.assertIdentical(protocol.response.length, UNKNOWN_LENGTH) | The multi-line response headers are folded and added to the response
object's C{headers} L{Headers} instance. | test_responseHeadersMultiline | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_connectionHeaders(self):
"""
The connection control headers are added to the parser's C{connHeaders}
L{Headers} instance.
"""
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None),
lambda rest: None)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
protocol.dataReceived(b'Content-Length: 123\r\n')
protocol.dataReceived(b'Connection: close\r\n')
protocol.dataReceived(b'\r\n')
self.assertEqual(
protocol.response.headers,
Headers({}))
self.assertEqual(
protocol.connHeaders,
Headers({b'content-length': [b'123'],
b'connection': [b'close']}))
self.assertEqual(protocol.response.length, 123) | The connection control headers are added to the parser's C{connHeaders}
L{Headers} instance. | test_connectionHeaders | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_headResponseContentLengthEntityHeader(self):
"""
If a HEAD request is made, the I{Content-Length} header in the response
is added to the response headers, not the connection control headers.
"""
protocol = HTTPClientParser(
Request(b'HEAD', b'/', _boringHeaders, None),
lambda rest: None)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
protocol.dataReceived(b'Content-Length: 123\r\n')
protocol.dataReceived(b'\r\n')
self.assertEqual(
protocol.response.headers,
Headers({b'content-length': [b'123']}))
self.assertEqual(
protocol.connHeaders,
Headers({}))
self.assertEqual(protocol.response.length, 0) | If a HEAD request is made, the I{Content-Length} header in the response
is added to the response headers, not the connection control headers. | test_headResponseContentLengthEntityHeader | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_contentLength(self):
"""
If a response includes a body with a length given by the
I{Content-Length} header, the bytes which make up the body are passed
to the C{_bodyDataReceived} callback on the L{HTTPParser}.
"""
finished = []
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None),
finished.append)
transport = StringTransport()
protocol.makeConnection(transport)
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
body = []
protocol.response._bodyDataReceived = body.append
protocol.dataReceived(b'Content-Length: 10\r\n')
protocol.dataReceived(b'\r\n')
# Incidentally, the transport should be paused now. It is the response
# object's responsibility to resume this when it is ready for bytes.
self.assertEqual(transport.producerState, u'paused')
self.assertEqual(protocol.state, BODY)
protocol.dataReceived(b'x' * 6)
self.assertEqual(body, [b'x' * 6])
self.assertEqual(protocol.state, BODY)
protocol.dataReceived(b'y' * 4)
self.assertEqual(body, [b'x' * 6, b'y' * 4])
self.assertEqual(protocol.state, DONE)
self.assertEqual(finished, [b'']) | If a response includes a body with a length given by the
I{Content-Length} header, the bytes which make up the body are passed
to the C{_bodyDataReceived} callback on the L{HTTPParser}. | test_contentLength | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_zeroContentLength(self):
"""
If a response includes a I{Content-Length} header indicating zero bytes
in the response, L{Response.length} is set accordingly and no data is
delivered to L{Response._bodyDataReceived}.
"""
finished = []
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None),
finished.append)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
body = []
protocol.response._bodyDataReceived = body.append
protocol.dataReceived(b'Content-Length: 0\r\n')
protocol.dataReceived(b'\r\n')
self.assertEqual(protocol.state, DONE)
self.assertEqual(body, [])
self.assertEqual(finished, [b''])
self.assertEqual(protocol.response.length, 0) | If a response includes a I{Content-Length} header indicating zero bytes
in the response, L{Response.length} is set accordingly and no data is
delivered to L{Response._bodyDataReceived}. | test_zeroContentLength | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_multipleContentLengthHeaders(self):
"""
If a response includes multiple I{Content-Length} headers,
L{HTTPClientParser.dataReceived} raises L{ValueError} to indicate that
the response is invalid and the transport is now unusable.
"""
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None),
None)
protocol.makeConnection(StringTransport())
self.assertRaises(
ValueError,
protocol.dataReceived,
b'HTTP/1.1 200 OK\r\n'
b'Content-Length: 1\r\n'
b'Content-Length: 2\r\n'
b'\r\n') | If a response includes multiple I{Content-Length} headers,
L{HTTPClientParser.dataReceived} raises L{ValueError} to indicate that
the response is invalid and the transport is now unusable. | test_multipleContentLengthHeaders | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_extraBytesPassedBack(self):
"""
If extra bytes are received past the end of a response, they are passed
to the finish callback.
"""
finished = []
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None),
finished.append)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
protocol.dataReceived(b'Content-Length: 0\r\n')
protocol.dataReceived(b'\r\nHere is another thing!')
self.assertEqual(protocol.state, DONE)
self.assertEqual(finished, [b'Here is another thing!']) | If extra bytes are received past the end of a response, they are passed
to the finish callback. | test_extraBytesPassedBack | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_extraBytesPassedBackHEAD(self):
"""
If extra bytes are received past the end of the headers of a response
to a HEAD request, they are passed to the finish callback.
"""
finished = []
protocol = HTTPClientParser(
Request(b'HEAD', b'/', _boringHeaders, None),
finished.append)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
protocol.dataReceived(b'Content-Length: 12\r\n')
protocol.dataReceived(b'\r\nHere is another thing!')
self.assertEqual(protocol.state, DONE)
self.assertEqual(finished, [b'Here is another thing!']) | If extra bytes are received past the end of the headers of a response
to a HEAD request, they are passed to the finish callback. | test_extraBytesPassedBackHEAD | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_chunkedResponseBody(self):
"""
If the response headers indicate the response body is encoded with the
I{chunked} transfer encoding, the body is decoded according to that
transfer encoding before being passed to L{Response._bodyDataReceived}.
"""
finished = []
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None),
finished.append)
protocol.makeConnection(StringTransport())
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
body = []
protocol.response._bodyDataReceived = body.append
protocol.dataReceived(b'Transfer-Encoding: chunked\r\n')
protocol.dataReceived(b'\r\n')
# No data delivered yet
self.assertEqual(body, [])
# Cannot predict the length of a chunked encoded response body.
self.assertIdentical(protocol.response.length, UNKNOWN_LENGTH)
# Deliver some chunks and make sure the data arrives
protocol.dataReceived(b'3\r\na')
self.assertEqual(body, [b'a'])
protocol.dataReceived(b'bc\r\n')
self.assertEqual(body, [b'a', b'bc'])
# The response's _bodyDataFinished method should be called when the last
# chunk is received. Extra data should be passed to the finished
# callback.
protocol.dataReceived(b'0\r\n\r\nextra')
self.assertEqual(finished, [b'extra']) | If the response headers indicate the response body is encoded with the
I{chunked} transfer encoding, the body is decoded according to that
transfer encoding before being passed to L{Response._bodyDataReceived}. | test_chunkedResponseBody | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_unknownContentLength(self):
"""
If a response does not include a I{Transfer-Encoding} or a
I{Content-Length}, the end of response body is indicated by the
connection being closed.
"""
finished = []
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None), finished.append)
transport = StringTransport()
protocol.makeConnection(transport)
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
body = []
protocol.response._bodyDataReceived = body.append
protocol.dataReceived(b'\r\n')
protocol.dataReceived(b'foo')
protocol.dataReceived(b'bar')
self.assertEqual(body, [b'foo', b'bar'])
protocol.connectionLost(ConnectionDone(u"simulated end of connection"))
self.assertEqual(finished, [b'']) | If a response does not include a I{Transfer-Encoding} or a
I{Content-Length}, the end of response body is indicated by the
connection being closed. | test_unknownContentLength | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_contentLengthAndTransferEncoding(self):
"""
According to RFC 2616, section 4.4, point 3, if I{Content-Length} and
I{Transfer-Encoding: chunked} are present, I{Content-Length} MUST be
ignored
"""
finished = []
protocol = HTTPClientParser(
Request(b'GET', b'/', _boringHeaders, None), finished.append)
transport = StringTransport()
protocol.makeConnection(transport)
protocol.dataReceived(b'HTTP/1.1 200 OK\r\n')
body = []
protocol.response._bodyDataReceived = body.append
protocol.dataReceived(
b'Content-Length: 102\r\n'
b'Transfer-Encoding: chunked\r\n'
b'\r\n'
b'3\r\n'
b'abc\r\n'
b'0\r\n'
b'\r\n')
self.assertEqual(body, [b'abc'])
self.assertEqual(finished, [b'']) | According to RFC 2616, section 4.4, point 3, if I{Content-Length} and
I{Transfer-Encoding: chunked} are present, I{Content-Length} MUST be
ignored | test_contentLengthAndTransferEncoding | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
def test_connectionLostBeforeBody(self):
"""
If L{HTTPClientParser.connectionLost} is called before the headers are
finished, the C{_responseDeferred} is fired with the L{Failure} passed
to C{connectionLost}.
"""
transport = StringTransport()
protocol = HTTPClientParser(Request(b'GET', b'/', _boringHeaders,
None), None)
protocol.makeConnection(transport)
# Grab this here because connectionLost gets rid of the attribute
responseDeferred = protocol._responseDeferred
protocol.connectionLost(Failure(ArbitraryException()))
return assertResponseFailed(
self, responseDeferred, [ArbitraryException]) | If L{HTTPClientParser.connectionLost} is called before the headers are
finished, the C{_responseDeferred} is fired with the L{Failure} passed
to C{connectionLost}. | test_connectionLostBeforeBody | python | wistbean/learn_python3_spider | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.