Back to index

python3.2  3.2.2
Classes | Public Member Functions | Static Public Attributes
test.test_memoryio.CStringIOPickleTest Class Reference
Inheritance diagram for test.test_memoryio.CStringIOPickleTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_memoryio.CStringIOPickleTest:
Collaboration graph
[legend]

List of all members.

Classes

class  ioclass

Public Member Functions

def test_newlines_property
def test_relative_seek
def test_textio_properties
def test_newline_none
def test_newline_empty
def test_newline_lf
def test_newline_cr
def test_newline_crlf
def test_issue5265
def test_newline_argument

Static Public Attributes

 UnsupportedOperation = io.UnsupportedOperation
 buftype = str
string EOF = ""

Detailed Description

Definition at line 705 of file test_memoryio.py.


Member Function Documentation

Definition at line 592 of file test_memoryio.py.

00592 
00593     def test_issue5265(self):
00594         # StringIO can duplicate newlines in universal newlines mode
00595         memio = self.ioclass("a\r\nb\r\n", newline=None)
00596         self.assertEqual(memio.read(5), "a\nb\n")

Here is the call graph for this function:

Definition at line 597 of file test_memoryio.py.

00597 
00598     def test_newline_argument(self):
00599         self.assertRaises(TypeError, self.ioclass, newline=b"\n")
00600         self.assertRaises(ValueError, self.ioclass, newline="error")
00601         # These should not raise an error
00602         for newline in (None, "", "\n", "\r", "\r\n"):
00603             self.ioclass(newline=newline)
00604 

Here is the call graph for this function:

Definition at line 578 of file test_memoryio.py.

00578 
00579     def test_newline_cr(self):
00580         # newline="\r"
00581         memio = self.ioclass("a\nb\r\nc\rd", newline="\r")
00582         self.assertEqual(memio.read(), "a\rb\r\rc\rd")
00583         memio.seek(0)
00584         self.assertEqual(list(memio), ["a\r", "b\r", "\r", "c\r", "d"])

Here is the call graph for this function:

Definition at line 585 of file test_memoryio.py.

00585 
00586     def test_newline_crlf(self):
00587         # newline="\r\n"
00588         memio = self.ioclass("a\nb\r\nc\rd", newline="\r\n")
00589         self.assertEqual(memio.read(), "a\r\nb\r\r\nc\rd")
00590         memio.seek(0)
00591         self.assertEqual(list(memio), ["a\r\n", "b\r\r\n", "c\rd"])

Here is the call graph for this function:

Definition at line 557 of file test_memoryio.py.

00557 
00558     def test_newline_empty(self):
00559         # newline=""
00560         memio = self.ioclass("a\nb\r\nc\rd", newline="")
00561         self.assertEqual(list(memio), ["a\n", "b\r\n", "c\r", "d"])
00562         memio.seek(0)
00563         self.assertEqual(memio.read(4), "a\nb\r")
00564         self.assertEqual(memio.read(2), "\nc")
00565         self.assertEqual(memio.read(1), "\r")
00566         memio = self.ioclass(newline="")
00567         self.assertEqual(2, memio.write("a\n"))
00568         self.assertEqual(2, memio.write("b\r"))
00569         self.assertEqual(2, memio.write("\nc"))
00570         self.assertEqual(2, memio.write("\rd"))
00571         memio.seek(0)
00572         self.assertEqual(list(memio), ["a\n", "b\r\n", "c\r", "d"])

Here is the call graph for this function:

Definition at line 573 of file test_memoryio.py.

00573 
00574     def test_newline_lf(self):
00575         # newline="\n"
00576         memio = self.ioclass("a\nb\r\nc\rd")
00577         self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"])

Here is the call graph for this function:

Definition at line 539 of file test_memoryio.py.

00539 
00540     def test_newline_none(self):
00541         # newline=None
00542         memio = self.ioclass("a\nb\r\nc\rd", newline=None)
00543         self.assertEqual(list(memio), ["a\n", "b\n", "c\n", "d"])
00544         memio.seek(0)
00545         self.assertEqual(memio.read(1), "a")
00546         self.assertEqual(memio.read(2), "\nb")
00547         self.assertEqual(memio.read(2), "\nc")
00548         self.assertEqual(memio.read(1), "\n")
00549         memio = self.ioclass(newline=None)
00550         self.assertEqual(2, memio.write("a\n"))
00551         self.assertEqual(3, memio.write("b\r\n"))
00552         self.assertEqual(3, memio.write("c\rd"))
00553         memio.seek(0)
00554         self.assertEqual(memio.read(), "a\nb\nc\nd")
00555         memio = self.ioclass("a\r\nb", newline=None)
00556         self.assertEqual(memio.read(3), "a\nb")

Here is the call graph for this function:

Definition at line 501 of file test_memoryio.py.

00501 
00502     def test_newlines_property(self):
00503         memio = self.ioclass(newline=None)
00504         # The C StringIO decodes newlines in write() calls, but the Python
00505         # implementation only does when reading.  This function forces them to
00506         # be decoded for testing.
00507         def force_decode():
00508             memio.seek(0)
00509             memio.read()
00510         self.assertEqual(memio.newlines, None)
00511         memio.write("a\n")
00512         force_decode()
00513         self.assertEqual(memio.newlines, "\n")
00514         memio.write("b\r\n")
00515         force_decode()
00516         self.assertEqual(memio.newlines, ("\n", "\r\n"))
00517         memio.write("c\rd")
00518         force_decode()
00519         self.assertEqual(memio.newlines, ("\r", "\n", "\r\n"))

Here is the call graph for this function:

Definition at line 520 of file test_memoryio.py.

00520 
00521     def test_relative_seek(self):
00522         memio = self.ioclass()
00523 
00524         self.assertRaises(IOError, memio.seek, -1, 1)
00525         self.assertRaises(IOError, memio.seek, 3, 1)
00526         self.assertRaises(IOError, memio.seek, -3, 1)
00527         self.assertRaises(IOError, memio.seek, -1, 2)
00528         self.assertRaises(IOError, memio.seek, 1, 1)
00529         self.assertRaises(IOError, memio.seek, 1, 2)

Here is the call graph for this function:

Definition at line 530 of file test_memoryio.py.

00530 
00531     def test_textio_properties(self):
00532         memio = self.ioclass()
00533 
00534         # These are just dummy values but we nevertheless check them for fear
00535         # of unexpected breakage.
00536         self.assertIsNone(memio.encoding)
00537         self.assertIsNone(memio.errors)
00538         self.assertFalse(memio.line_buffering)

Here is the call graph for this function:


Member Data Documentation

Definition at line 616 of file test_memoryio.py.

Definition at line 618 of file test_memoryio.py.

Reimplemented from test.test_memoryio.PyStringIOPickleTest.

Definition at line 706 of file test_memoryio.py.


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