You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The assertions function/functions are invoked with a PreparedRequest object that can be unwieldy to work with. For example, a URL containing encoded query parameters aren't fun to work with.
Python's standard library urllib.parse to the rescue!
We can use urllib.parse.urlparse combined with urllib.parse.parse_qs to break the URL apart into its components and then provide nicer abstractions to work with when writing assertions functions.
parse_qs returns a dict where the keys are lists as the same query parameter can be occur multiple times in the same string. This needs to be handled. At the same time, it'd be helpful to unpack single values so that assertions doesn't have to wrap the expected value in a list.
The assertions function/functions are invoked with a
PreparedRequest
object that can be unwieldy to work with. For example, a URL containing encoded query parameters aren't fun to work with.Python's standard library
urllib.parse
to the rescue!We can use
urllib.parse.urlparse
combined withurllib.parse.parse_qs
to break the URL apart into its components and then provide nicer abstractions to work with when writing assertions functions.The text was updated successfully, but these errors were encountered: