class URITests: (source)
Known subclasses: twisted.web.test.test_webclient.URITestsForHostname
, twisted.web.test.test_webclient.URITestsForIPv4
, twisted.web.test.test_webclient.URITestsForIPv6
Abstract tests for twisted.web.client.URI
.
Subclass this and unittest.TestCase
. Then provide a value for host and uriHost.
Method | assert |
Assert that all of a client.URI 's components match the expected values. |
Method | make |
Replace the string "HOST" in template with this test's host. |
Method | test_empty |
The path of a URI with an empty path is b'/'. |
Method | test_external |
client.URI.fromBytes parses the scheme, host, and path elements into bytes , even when passed an URL which has previously been passed to urlparse as a unicode string. |
Method | test |
Parse the fragment identifier from a URI. |
Method | test_netloc |
Parsing a URI splits the network location component into host and port. |
Method | test_no |
The path of a URI that has no path is the empty string. |
Method | test_origin |
client.URI.originForm produces an absolute URI path including the URI path. |
Method | test_origin |
client.URI.originForm produces an absolute URI path including the URI path, parameters and query string but excludes the fragment identifier. |
Method | test_origin |
client.URI.originForm produces a path of b'/' when the URI specifies an empty path. |
Method | test_origin |
client.URI.originForm produces a path of b'/' when the URI specifies no path. |
Method | test |
Parse URI parameters from a URI. |
Method | test_parse |
client.URI.fromBytes accepts a defaultPort parameter that overrides the normal default port logic. |
Method | test_parse |
client.URI.fromBytes by default assumes port 80 for the http scheme and 443 for the https scheme. |
Method | test |
Parse the path from a URI. |
Method | test |
Parse the query string from a URI. |
Instance Variable | host |
A host specification for use in tests, must be bytes . |
Instance Variable | uri |
The host specification in URI form, must be a bytes . In most cases this is identical with host. IPv6 address literals are an exception, according to RFC 3986 section 3.2.2, as they need to be enclosed in brackets... |
Assert that all of a client.URI
's components match the expected values.
Parameters | |
uri | client.URI instance whose attributes will be checked for equality. |
scheme:bytes | URI scheme specifier. |
netloc:bytes | Network location component. |
host:bytes | Host name. |
port:int | Port number. |
path:bytes | Hierarchical path. |
params:bytes | Parameters for last path segment, defaults to b''. |
query:bytes | Query string, defaults to b''. |
fragment:bytes | Fragment identifier, defaults to b''. |
Replace the string "HOST" in template with this test's host.
Byte strings Python between (and including) versions 3.0 and 3.4 cannot be formatted using % or format so this does a simple replace.
Parameters | |
template:bytes | A string containing "HOST". |
Returns | |
bytes | A string where "HOST" has been replaced by self.host. |
client.URI.fromBytes
parses the scheme, host, and path elements into bytes
, even when passed an URL which has previously been passed to urlparse
as a unicode
string.
client.URI.originForm
produces an absolute URI path including the URI path, parameters and query string but excludes the fragment identifier.
twisted.web.test.test_webclient.URITestsForHostname
, twisted.web.test.test_webclient.URITestsForIPv4
, twisted.web.test.test_webclient.URITestsForIPv6
A host specification for use in tests, must be bytes
.
twisted.web.test.test_webclient.URITestsForHostname
, twisted.web.test.test_webclient.URITestsForIPv4
, twisted.web.test.test_webclient.URITestsForIPv6
The host specification in URI form, must be a bytes
. In most cases this is identical with host. IPv6 address literals are an exception, according to RFC 3986 section 3.2.2, as they need to be enclosed in brackets. In this case this variable is different.