Skip to content
Myr

basic tests

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 82cce02 · Browse files · 1 file+43 added−0 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+43 added−0 removed

  • other:+43 added−0 removed

1 file+43 added−0 removed

modified:test_requests.py+43 added
1 unmodified line
2# -*- coding: utf-8 -*-34"""Tests for Requests."""56import os7import unittest89import requests1011httpbin = os.environ.get('HTTPBIN_URL', 'http://httpbin.org/')1213class RequestsTestCase(unittest.TestCase):1415 _multiprocess_can_split_ = True1617 def setUp(self):18 """Create simple data set with headers."""19 pass20
3 unmodified lines
2425 def test_assertion(self):26 assert 12728 def test_entry_points(self):2930 requests.session31 requests.session().get32 requests.session().head33 requests.get34 requests.head35 requests.put36 requests.patch37 requests.post3839 def test_invalid_url(self):40 self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')4142 def test_basic_building(self):43 req = requests.Request()44 req.url = 'http://kennethreitz.org/'45 req.data = {'life': '42'}4647 pr = req.prepare()48 assert pr.url == req.url49 assert pr.body == 'life=42'505152 def test_path_is_not_double_encoded(self):53 request = requests.Request('GET', "http://0.0.0.0/get/test case").prepare()5455 self.assertEqual(request.path_url, "/get/test%20case")5657 def test_params_are_added_before_fragment(self):58 request = requests.Request('GET',59 "http://example.com/path#fragment", params={"a": "b"}).prepare()60 self.assertEqual(request.url,61 "http://example.com/path?a=b#fragment")62 request = requests.Request('GET',63 "http://example.com/path?key=value#fragment", params={"a": "b"}).prepare()64 self.assertEqual(request.url,65 "http://example.com/path?key=value&a=b#fragment")6667if __name__ == '__main__':68 unittest.main()