Skip to content
Myr

test_requests: Add tests for morsel_to_cookie

Before adoption: this commit came in with the history the project adopted, so no landing records it.

These tests will ensure my changes to how we handle 'expires' don't cause any regressions.

authored by Michael Becker · committed by Michael Becker · parent 3235766 · Browse files · 1 file+23 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−4 removed

  • other:+23 added−4 removed

1 file+23 added−4 removed

modified:test_requests.py+23 added-4 removed
4 unmodified lines
56from __future__ import division7import json8import os9import unittest9import pickle10import unittest1112import requests13import pytest14from requests.auth import HTTPDigestAuth14from requests.adapters import HTTPAdapter16from requests.compat import str, cookielib, getproxies, urljoin, urlparse17from requests.cookies import cookiejar_from_dict15from requests.auth import HTTPDigestAuth16from requests.compat import (17 Morsel, cookielib, getproxies, str, urljoin, urlparse)18from requests.cookies import cookiejar_from_dict, morsel_to_cookie19from requests.exceptions import InvalidURL, MissingSchema20from requests.structures import CaseInsensitiveDict2122try:
736 unmodified lines
759 req = requests.Request('GET', test_url)760 preq = req.prepare()761 assert test_url == preq.url762763 def test_morsel_to_cookie_expires_is_converted(self):764 morsel = Morsel()765766 # Test case where we convert from string time767 morsel['expires'] = 'Thu, 01-Jan-1970 00:00:01 GMT'768 cookie = morsel_to_cookie(morsel)769 self.assertEquals(cookie.expires, 18001)770771 # Test case where no conversion is required772 morsel['expires'] = 100773 cookie = morsel_to_cookie(morsel)774 self.assertEquals(cookie.expires, 100)775776 # Test case where an invalid string is input777 morsel['expires'] = 'woops'778 with self.assertRaises(ValueError):779 cookie = morsel_to_cookie(morsel)780781782class TestContentEncodingDetection(unittest.TestCase):783784 def test_none(self):785 encodings = requests.utils.get_encodings_from_content('')
242 unmodified lines