Back to index

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

List of all members.

Public Member Functions

def test_basic
def test_join
def test_pickle
def test_copy

Static Public Attributes

 type2test = bytes
 subclass2test = BytesSubclass

Detailed Description

Definition at line 1200 of file test_bytes.py.


Member Function Documentation

def test.test_bytes.SubclassTest.test_basic (   self) [inherited]

Definition at line 1115 of file test_bytes.py.

01115 
01116     def test_basic(self):
01117         self.assertTrue(issubclass(self.subclass2test, self.type2test))
01118         self.assertIsInstance(self.subclass2test(), self.type2test)
01119 
01120         a, b = b"abcd", b"efgh"
01121         _a, _b = self.subclass2test(a), self.subclass2test(b)
01122 
01123         # test comparison operators with subclass instances
01124         self.assertTrue(_a == _a)
01125         self.assertTrue(_a != _b)
01126         self.assertTrue(_a < _b)
01127         self.assertTrue(_a <= _b)
01128         self.assertTrue(_b >= _a)
01129         self.assertTrue(_b > _a)
01130         self.assertTrue(_a is not a)
01131 
01132         # test concat of subclass instances
01133         self.assertEqual(a + b, _a + _b)
01134         self.assertEqual(a + b, a + _b)
01135         self.assertEqual(a + b, _a + b)
01136 
01137         # test repeat
01138         self.assertTrue(a*5 == _a*5)

Here is the call graph for this function:

def test.test_bytes.SubclassTest.test_copy (   self) [inherited]

Definition at line 1165 of file test_bytes.py.

01165 
01166     def test_copy(self):
01167         a = self.subclass2test(b"abcd")
01168         a.x = 10
01169         a.y = self.subclass2test(b"efgh")
01170         for copy_method in (copy.copy, copy.deepcopy):
01171             b = copy_method(a)
01172             self.assertNotEqual(id(a), id(b))
01173             self.assertEqual(a, b)
01174             self.assertEqual(a.x, b.x)
01175             self.assertEqual(a.y, b.y)
01176             self.assertEqual(type(a), type(b))
01177             self.assertEqual(type(a.y), type(b.y))
01178 

Here is the call graph for this function:

def test.test_bytes.SubclassTest.test_join (   self) [inherited]

Definition at line 1139 of file test_bytes.py.

01139 
01140     def test_join(self):
01141         # Make sure join returns a NEW object for single item sequences
01142         # involving a subclass.
01143         # Make sure that it is of the appropriate type.
01144         s1 = self.subclass2test(b"abcd")
01145         s2 = self.type2test().join([s1])
01146         self.assertTrue(s1 is not s2)
01147         self.assertTrue(type(s2) is self.type2test, type(s2))
01148 
01149         # Test reverse, calling join on subclass
01150         s3 = s1.join([b"abcd"])
01151         self.assertTrue(type(s3) is self.type2test)

Here is the call graph for this function:

def test.test_bytes.SubclassTest.test_pickle (   self) [inherited]

Definition at line 1152 of file test_bytes.py.

01152 
01153     def test_pickle(self):
01154         a = self.subclass2test(b"abcd")
01155         a.x = 10
01156         a.y = self.subclass2test(b"efgh")
01157         for proto in range(pickle.HIGHEST_PROTOCOL + 1):
01158             b = pickle.loads(pickle.dumps(a, proto))
01159             self.assertNotEqual(id(a), id(b))
01160             self.assertEqual(a, b)
01161             self.assertEqual(a.x, b.x)
01162             self.assertEqual(a.y, b.y)
01163             self.assertEqual(type(a), type(b))
01164             self.assertEqual(type(a.y), type(b.y))

Here is the call graph for this function:


Member Data Documentation

Definition at line 1202 of file test_bytes.py.

Definition at line 1201 of file test_bytes.py.


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