twisted.web.test.test_webclient.URITests
class documentationtwisted.web.test.test_webclient
(View In Hierarchy)
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
.
Instance Variable | host | A host specification for use in tests, must be bytes . |
Instance Variable | uriHost | 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. |
Method | makeURIString | Replace the string "HOST" in template with this
test's host. |
Method | assertURIEquals | Assert that all of a client.URI 's components
match the expected values. |
Method | test_parseDefaultPort | client.URI.fromBytes
by default assumes port 80 for the http scheme and 443 for the
https scheme. |
Method | test_parseCustomDefaultPort | client.URI.fromBytes
accepts a defaultPort parameter that overrides the normal
default port logic. |
Method | test_netlocHostPort | Parsing a URI splits the network location component into host and port. |
Method | test_path | Parse the path from a URI. |
Method | test_noPath | The path of a URI that has no path is the empty string. |
Method | test_emptyPath | The path of a URI with an empty path is b'/' . |
Method | test_param | Parse URI parameters from a URI. |
Method | test_query | Parse the query string from a URI. |
Method | test_fragment | Parse the fragment identifier from a URI. |
Method | test_originForm | client.URI.originForm
produces an absolute URI path including the URI path. |
Method | test_originFormComplex | client.URI.originForm
produces an absolute URI path including the URI path,
parameters and query string but excludes the fragment identifier. |
Method | test_originFormNoPath | client.URI.originForm
produces a path of b'/' when the URI specifies no
path. |
Method | test_originFormEmptyPath | client.URI.originForm
produces a path of b'/' when the URI specifies an empty
path. |
Method | test_externalUnicodeInterference | 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. |
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.
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 | A string containing "HOST". (type: bytes ) |
Returns | A string where "HOST" has been replaced by
self.host . (type: bytes ) |
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 | URI scheme specifier. (type: bytes ) | |
netloc | Network location component. (type: bytes ) | |
host | Host name. (type: bytes ) | |
port | Port number. (type: int ) | |
path | Hierarchical path. (type: bytes ) | |
params | Parameters for last path segment, defaults to b'' . (type: bytes ) | |
query | Query string, defaults to b'' . (type: bytes ) | |
fragment | Fragment identifier, defaults to b'' . (type: bytes ) |
client.URI.fromBytes
by default assumes port 80 for the http scheme and 443 for the
https scheme.
client.URI.fromBytes
accepts a defaultPort
parameter that overrides the normal
default port logic.
Parsing a URI splits the network location component into host and port.
client.URI.originForm
produces an absolute URI path including the URI path.
client.URI.originForm
produces an absolute URI path including the URI path,
parameters and query string but excludes the fragment identifier.
client.URI.originForm
produces a path of b'/'
when the URI specifies no
path.
client.URI.originForm
produces a path of b'/'
when the URI specifies an empty
path.
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.