Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_httplib.RequestBodyTest Class Reference
Inheritance diagram for test.test_httplib.RequestBodyTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_httplib.RequestBodyTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def get_headers_and_fp
def test_manual_content_length
def test_ascii_body
def test_latin1_body
def test_bytes_body
def test_file_body
def test_binary_file_body

Public Attributes

 conn
 sock

Detailed Description

Test cases where a request includes a message body.

Definition at line 543 of file test_httplib.py.


Member Function Documentation

Definition at line 551 of file test_httplib.py.

00551 
00552     def get_headers_and_fp(self):
00553         f = io.BytesIO(self.sock.data)
00554         f.readline()  # read the request line
00555         message = client.parse_headers(f)
00556         return message, f

Here is the caller graph for this function:

Definition at line 546 of file test_httplib.py.

00546 
00547     def setUp(self):
00548         self.conn = client.HTTPConnection('example.com')
00549         self.conn.sock = self.sock = FakeSocket("")
00550         self.conn.sock = self.sock

Here is the caller graph for this function:

Definition at line 566 of file test_httplib.py.

00566 
00567     def test_ascii_body(self):
00568         self.conn.request("PUT", "/url", "body")
00569         message, f = self.get_headers_and_fp()
00570         self.assertEqual("text/plain", message.get_content_type())
00571         self.assertIsNone(message.get_charset())
00572         self.assertEqual("4", message.get("content-length"))
00573         self.assertEqual(b'body', f.read())

Here is the call graph for this function:

Definition at line 601 of file test_httplib.py.

00601 
00602     def test_binary_file_body(self):
00603         with open(support.TESTFN, "wb") as f:
00604             f.write(b"body\xc1")
00605         with open(support.TESTFN, "rb") as f:
00606             self.conn.request("PUT", "/url", f)
00607             message, f = self.get_headers_and_fp()
00608             self.assertEqual("text/plain", message.get_content_type())
00609             self.assertIsNone(message.get_charset())
00610             self.assertEqual("5", message.get("content-length"))
00611             self.assertEqual(b'body\xc1', f.read())
00612 

Here is the call graph for this function:

Definition at line 582 of file test_httplib.py.

00582 
00583     def test_bytes_body(self):
00584         self.conn.request("PUT", "/url", b"body\xc1")
00585         message, f = self.get_headers_and_fp()
00586         self.assertEqual("text/plain", message.get_content_type())
00587         self.assertIsNone(message.get_charset())
00588         self.assertEqual("5", message.get("content-length"))
00589         self.assertEqual(b'body\xc1', f.read())

Here is the call graph for this function:

Definition at line 590 of file test_httplib.py.

00590 
00591     def test_file_body(self):
00592         with open(support.TESTFN, "w") as f:
00593             f.write("body")
00594         with open(support.TESTFN) as f:
00595             self.conn.request("PUT", "/url", f)
00596             message, f = self.get_headers_and_fp()
00597             self.assertEqual("text/plain", message.get_content_type())
00598             self.assertIsNone(message.get_charset())
00599             self.assertEqual("4", message.get("content-length"))
00600             self.assertEqual(b'body', f.read())

Here is the call graph for this function:

Definition at line 574 of file test_httplib.py.

00574 
00575     def test_latin1_body(self):
00576         self.conn.request("PUT", "/url", "body\xc1")
00577         message, f = self.get_headers_and_fp()
00578         self.assertEqual("text/plain", message.get_content_type())
00579         self.assertIsNone(message.get_charset())
00580         self.assertEqual("5", message.get("content-length"))
00581         self.assertEqual(b'body\xc1', f.read())

Here is the call graph for this function:

Definition at line 557 of file test_httplib.py.

00557 
00558     def test_manual_content_length(self):
00559         # Set an incorrect content-length so that we can verify that
00560         # it will not be over-ridden by the library.
00561         self.conn.request("PUT", "/url", "body",
00562                           {"Content-Length": "42"})
00563         message, f = self.get_headers_and_fp()
00564         self.assertEqual("42", message.get("content-length"))
00565         self.assertEqual(4, len(f.read()))

Here is the call graph for this function:


Member Data Documentation

Definition at line 547 of file test_httplib.py.

Definition at line 548 of file test_httplib.py.


The documentation for this class was generated from the following file: