mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
basic tests
This commit is contained in:
@@ -3,13 +3,17 @@
|
||||
|
||||
"""Tests for Requests."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import requests
|
||||
|
||||
httpbin = os.environ.get('HTTPBIN_URL', 'http://httpbin.org/')
|
||||
|
||||
class RequestsTestCase(unittest.TestCase):
|
||||
|
||||
_multiprocess_can_split_ = True
|
||||
|
||||
def setUp(self):
|
||||
"""Create simple data set with headers."""
|
||||
pass
|
||||
@@ -21,5 +25,44 @@ class RequestsTestCase(unittest.TestCase):
|
||||
def test_assertion(self):
|
||||
assert 1
|
||||
|
||||
def test_entry_points(self):
|
||||
|
||||
requests.session
|
||||
requests.session().get
|
||||
requests.session().head
|
||||
requests.get
|
||||
requests.head
|
||||
requests.put
|
||||
requests.patch
|
||||
requests.post
|
||||
|
||||
def test_invalid_url(self):
|
||||
self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')
|
||||
|
||||
def test_basic_building(self):
|
||||
req = requests.Request()
|
||||
req.url = 'http://kennethreitz.org/'
|
||||
req.data = {'life': '42'}
|
||||
|
||||
pr = req.prepare()
|
||||
assert pr.url == req.url
|
||||
assert pr.body == 'life=42'
|
||||
|
||||
|
||||
def test_path_is_not_double_encoded(self):
|
||||
request = requests.Request('GET', "http://0.0.0.0/get/test case").prepare()
|
||||
|
||||
self.assertEqual(request.path_url, "/get/test%20case")
|
||||
|
||||
def test_params_are_added_before_fragment(self):
|
||||
request = requests.Request('GET',
|
||||
"http://example.com/path#fragment", params={"a": "b"}).prepare()
|
||||
self.assertEqual(request.url,
|
||||
"http://example.com/path?a=b#fragment")
|
||||
request = requests.Request('GET',
|
||||
"http://example.com/path?key=value#fragment", params={"a": "b"}).prepare()
|
||||
self.assertEqual(request.url,
|
||||
"http://example.com/path?key=value&a=b#fragment")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user