Skip to content
Myr

test_requests: convert tests to py.test style

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

authored by Michael Becker · committed by Michael Becker · parent ea4570d · Browse files · 1 file+9 added−6 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+9 added−6 removed

  • other:+9 added−6 removed

1 file+9 added−6 removed

modified:test_requests.py+9 added-6 removed
1014 unmodified lines
10151016 morsel = Morsel()1017 morsel['expires'] = 'Thu, 01-Jan-1970 00:00:01 GMT'1018 cookie = morsel_to_cookie(morsel)1019 self.assertEquals(cookie.expires, 1)1019 assert cookie.expires == 110201021 def test_expires_invalid_int(self):1022 """Test case where an invalid type is passed for expires."""10231024 morsel = Morsel()1025 morsel['expires'] = 1001026 self.assertRaises(TypeError, morsel_to_cookie, (morsel))1026 with pytest.raises(TypeError):1027 morsel_to_cookie(morsel)10281029 def test_expires_invalid_str(self):1030 """Test case where an invalid string is input."""10311032 morsel = Morsel()1033 morsel['expires'] = 'woops'1033 self.assertRaises(ValueError, morsel_to_cookie, (morsel))1034 with pytest.raises(ValueError):1035 morsel_to_cookie(morsel)10361037 def test_expires_none(self):1038 """Test case where expires is None."""10391040 morsel = Morsel()1041 morsel['expires'] = None1042 cookie = morsel_to_cookie(morsel)1041 self.assertEquals(cookie.expires, None)1043 assert cookie.expires is None104410451046class TestMorselToCookieMaxAge(unittest.TestCase):1047
4 unmodified lines
10521053 morsel = Morsel()1054 morsel['max-age'] = 601055 cookie = morsel_to_cookie(morsel)1054 self.assertTrue(isinstance(cookie.expires, int))1056 assert isinstance(cookie.expires, int)10571058 def test_max_age_invalid_str(self):1059 """Test case where a invalid max age is passed."""10601061 morsel = Morsel()1062 morsel['max-age'] = 'woops'1061 self.assertRaises(TypeError, morsel_to_cookie, (morsel))1063 with pytest.raises(TypeError):1064 morsel_to_cookie(morsel)106510661067if __name__ == '__main__':1068 unittest.main()