I’ve been trying to add a few more unit test cases to increase the existing coverage value and noticed a few things. This thread is to track them and check to see if they are something that needs to be addressed and get a feedback from the community.
Cookies
Max-Age
The current implementation of the Cookie class attempts to set the cookie as follows.
try:
output.append("%s=%d" % (self._keys[key], value))
except TypeError:
output.append("%s=%s" % (self._keys[key], value))
I don’t think we need to have this try-except. Instead, we might be better off with enforcing the value of Max-Age to be integers. As per the HTTP Cookie standards, this can’t be anything but an integer value.
Expires
As per the HTTP Cookie standards, the format of the Expires has to adhere to Date: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
In our case, if the value can’t be converted into that format, we return the text/value as is.
Request
repr
The following condition check in the repr hook for the Request class seems unnecessary.
How would one get either of these items to be an empty value?
if self.method is None or not self.path:
return "<{0}>".format(self.__class__.__name__)
