Back to index

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

List of all members.

Public Member Functions

def marshal
def test_islower
def test_isupper
def test_istitle
def test_isspace
def test_isalpha
def test_isalnum
def test_isdigit
def test_lower
def test_upper
def test_capitalize
def test_ljust
def test_rjust
def test_center
def test_swapcase
def test_zfill
def test_expandtabs
def test_title
def test_splitlines

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Tests that work for both bytes and buffer objects.
See PEP 3137.

Definition at line 7 of file buffer_tests.py.


Member Function Documentation

Convert x into the appropriate type for these tests.

Reimplemented in test.test_bytes.BytearrayPEP3137Test.

Definition at line 12 of file buffer_tests.py.

00012 
00013     def marshal(self, x):
00014         """Convert x into the appropriate type for these tests."""
00015         raise RuntimeError('test class must provide a marshal method')

Here is the caller graph for this function:

Definition at line 101 of file buffer_tests.py.

00101 
00102     def test_capitalize(self):
00103         self.assertEqual(b' hello ', self.marshal(b' hello ').capitalize())
00104         self.assertEqual(b'Hello ', self.marshal(b'Hello ').capitalize())
00105         self.assertEqual(b'Hello ', self.marshal(b'hello ').capitalize())
00106         self.assertEqual(b'Aaaa', self.marshal(b'aaaa').capitalize())
00107         self.assertEqual(b'Aaaa', self.marshal(b'AaAa').capitalize())
00108 
00109         self.assertRaises(TypeError, self.marshal(b'hello').capitalize, 42)

Here is the call graph for this function:

Definition at line 126 of file buffer_tests.py.

00126 
00127     def test_center(self):
00128         self.assertEqual(b'   abc    ', self.marshal(b'abc').center(10))
00129         self.assertEqual(b' abc  ', self.marshal(b'abc').center(6))
00130         self.assertEqual(b'abc', self.marshal(b'abc').center(3))
00131         self.assertEqual(b'abc', self.marshal(b'abc').center(2))
00132         self.assertEqual(b'***abc****', self.marshal(b'abc').center(10, b'*'))
00133         self.assertRaises(TypeError, self.marshal(b'abc').center)

Here is the call graph for this function:

Definition at line 156 of file buffer_tests.py.

00156 
00157     def test_expandtabs(self):
00158         self.assertEqual(b'abc\rab      def\ng       hi',
00159                          self.marshal(b'abc\rab\tdef\ng\thi').expandtabs())
00160         self.assertEqual(b'abc\rab      def\ng       hi',
00161                          self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(8))
00162         self.assertEqual(b'abc\rab  def\ng   hi',
00163                          self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(4))
00164         self.assertEqual(b'abc\r\nab  def\ng   hi',
00165                          self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(4))
00166         self.assertEqual(b'abc\rab      def\ng       hi',
00167                          self.marshal(b'abc\rab\tdef\ng\thi').expandtabs())
00168         self.assertEqual(b'abc\rab      def\ng       hi',
00169                          self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(8))
00170         self.assertEqual(b'abc\r\nab\r\ndef\ng\r\nhi',
00171             self.marshal(b'abc\r\nab\r\ndef\ng\r\nhi').expandtabs(4))
00172         self.assertEqual(b'  a\n b', self.marshal(b' \ta\n\tb').expandtabs(1))
00173 
00174         self.assertRaises(TypeError, self.marshal(b'hello').expandtabs, 42, 42)
00175         # This test is only valid when sizeof(int) == sizeof(void*) == 4.
00176         if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4:
00177             self.assertRaises(OverflowError,
00178                               self.marshal(b'\ta\n\tb').expandtabs, sys.maxsize)

Here is the call graph for this function:

Definition at line 71 of file buffer_tests.py.

00071 
00072     def test_isalnum(self):
00073         self.assertFalse(self.marshal(b'').isalnum())
00074         self.assertTrue(self.marshal(b'a').isalnum())
00075         self.assertTrue(self.marshal(b'A').isalnum())
00076         self.assertFalse(self.marshal(b'\n').isalnum())
00077         self.assertTrue(self.marshal(b'123abc456').isalnum())
00078         self.assertTrue(self.marshal(b'a1b3c').isalnum())
00079         self.assertFalse(self.marshal(b'aBc000 ').isalnum())
00080         self.assertFalse(self.marshal(b'abc\n').isalnum())
00081         self.assertRaises(TypeError, self.marshal(b'abc').isalnum, 42)

Here is the call graph for this function:

Definition at line 61 of file buffer_tests.py.

00061 
00062     def test_isalpha(self):
00063         self.assertFalse(self.marshal(b'').isalpha())
00064         self.assertTrue(self.marshal(b'a').isalpha())
00065         self.assertTrue(self.marshal(b'A').isalpha())
00066         self.assertFalse(self.marshal(b'\n').isalpha())
00067         self.assertTrue(self.marshal(b'abc').isalpha())
00068         self.assertFalse(self.marshal(b'aBc123').isalpha())
00069         self.assertFalse(self.marshal(b'abc\n').isalpha())
00070         self.assertRaises(TypeError, self.marshal(b'abc').isalpha, 42)

Here is the call graph for this function:

Definition at line 82 of file buffer_tests.py.

00082 
00083     def test_isdigit(self):
00084         self.assertFalse(self.marshal(b'').isdigit())
00085         self.assertFalse(self.marshal(b'a').isdigit())
00086         self.assertTrue(self.marshal(b'0').isdigit())
00087         self.assertTrue(self.marshal(b'0123456789').isdigit())
00088         self.assertFalse(self.marshal(b'0123456789a').isdigit())
00089 
00090         self.assertRaises(TypeError, self.marshal(b'abc').isdigit, 42)

Here is the call graph for this function:

Definition at line 16 of file buffer_tests.py.

00016 
00017     def test_islower(self):
00018         self.assertFalse(self.marshal(b'').islower())
00019         self.assertTrue(self.marshal(b'a').islower())
00020         self.assertFalse(self.marshal(b'A').islower())
00021         self.assertFalse(self.marshal(b'\n').islower())
00022         self.assertTrue(self.marshal(b'abc').islower())
00023         self.assertFalse(self.marshal(b'aBc').islower())
00024         self.assertTrue(self.marshal(b'abc\n').islower())
00025         self.assertRaises(TypeError, self.marshal(b'abc').islower, 42)

Here is the call graph for this function:

Definition at line 50 of file buffer_tests.py.

00050 
00051     def test_isspace(self):
00052         self.assertFalse(self.marshal(b'').isspace())
00053         self.assertFalse(self.marshal(b'a').isspace())
00054         self.assertTrue(self.marshal(b' ').isspace())
00055         self.assertTrue(self.marshal(b'\t').isspace())
00056         self.assertTrue(self.marshal(b'\r').isspace())
00057         self.assertTrue(self.marshal(b'\n').isspace())
00058         self.assertTrue(self.marshal(b' \t\r\n').isspace())
00059         self.assertFalse(self.marshal(b' \t\r\na').isspace())
00060         self.assertRaises(TypeError, self.marshal(b'abc').isspace, 42)

Here is the call graph for this function:

Definition at line 36 of file buffer_tests.py.

00036 
00037     def test_istitle(self):
00038         self.assertFalse(self.marshal(b'').istitle())
00039         self.assertFalse(self.marshal(b'a').istitle())
00040         self.assertTrue(self.marshal(b'A').istitle())
00041         self.assertFalse(self.marshal(b'\n').istitle())
00042         self.assertTrue(self.marshal(b'A Titlecased Line').istitle())
00043         self.assertTrue(self.marshal(b'A\nTitlecased Line').istitle())
00044         self.assertTrue(self.marshal(b'A Titlecased, Line').istitle())
00045         self.assertFalse(self.marshal(b'Not a capitalized String').istitle())
00046         self.assertFalse(self.marshal(b'Not\ta Titlecase String').istitle())
00047         self.assertFalse(self.marshal(b'Not--a Titlecase String').istitle())
00048         self.assertFalse(self.marshal(b'NOT').istitle())
00049         self.assertRaises(TypeError, self.marshal(b'abc').istitle, 42)

Here is the call graph for this function:

Definition at line 26 of file buffer_tests.py.

00026 
00027     def test_isupper(self):
00028         self.assertFalse(self.marshal(b'').isupper())
00029         self.assertFalse(self.marshal(b'a').isupper())
00030         self.assertTrue(self.marshal(b'A').isupper())
00031         self.assertFalse(self.marshal(b'\n').isupper())
00032         self.assertTrue(self.marshal(b'ABC').isupper())
00033         self.assertFalse(self.marshal(b'AbC').isupper())
00034         self.assertTrue(self.marshal(b'ABC\n').isupper())
00035         self.assertRaises(TypeError, self.marshal(b'abc').isupper, 42)

Here is the call graph for this function:

Definition at line 110 of file buffer_tests.py.

00110 
00111     def test_ljust(self):
00112         self.assertEqual(b'abc       ', self.marshal(b'abc').ljust(10))
00113         self.assertEqual(b'abc   ', self.marshal(b'abc').ljust(6))
00114         self.assertEqual(b'abc', self.marshal(b'abc').ljust(3))
00115         self.assertEqual(b'abc', self.marshal(b'abc').ljust(2))
00116         self.assertEqual(b'abc*******', self.marshal(b'abc').ljust(10, b'*'))
00117         self.assertRaises(TypeError, self.marshal(b'abc').ljust)

Here is the call graph for this function:

Definition at line 91 of file buffer_tests.py.

00091 
00092     def test_lower(self):
00093         self.assertEqual(b'hello', self.marshal(b'HeLLo').lower())
00094         self.assertEqual(b'hello', self.marshal(b'hello').lower())
00095         self.assertRaises(TypeError, self.marshal(b'hello').lower, 42)

Here is the call graph for this function:

Definition at line 118 of file buffer_tests.py.

00118 
00119     def test_rjust(self):
00120         self.assertEqual(b'       abc', self.marshal(b'abc').rjust(10))
00121         self.assertEqual(b'   abc', self.marshal(b'abc').rjust(6))
00122         self.assertEqual(b'abc', self.marshal(b'abc').rjust(3))
00123         self.assertEqual(b'abc', self.marshal(b'abc').rjust(2))
00124         self.assertEqual(b'*******abc', self.marshal(b'abc').rjust(10, b'*'))
00125         self.assertRaises(TypeError, self.marshal(b'abc').rjust)

Here is the call graph for this function:

Definition at line 190 of file buffer_tests.py.

00190 
00191     def test_splitlines(self):
00192         self.assertEqual([b'abc', b'def', b'', b'ghi'],
00193                          self.marshal(b'abc\ndef\n\rghi').splitlines())
00194         self.assertEqual([b'abc', b'def', b'', b'ghi'],
00195                          self.marshal(b'abc\ndef\n\r\nghi').splitlines())
00196         self.assertEqual([b'abc', b'def', b'ghi'],
00197                          self.marshal(b'abc\ndef\r\nghi').splitlines())
00198         self.assertEqual([b'abc', b'def', b'ghi'],
00199                          self.marshal(b'abc\ndef\r\nghi\n').splitlines())
00200         self.assertEqual([b'abc', b'def', b'ghi', b''],
00201                          self.marshal(b'abc\ndef\r\nghi\n\r').splitlines())
00202         self.assertEqual([b'', b'abc', b'def', b'ghi', b''],
00203                          self.marshal(b'\nabc\ndef\r\nghi\n\r').splitlines())
00204         self.assertEqual([b'\n', b'abc\n', b'def\r\n', b'ghi\n', b'\r'],
00205                          self.marshal(b'\nabc\ndef\r\nghi\n\r').splitlines(1))
00206 
00207         self.assertRaises(TypeError, self.marshal(b'abc').splitlines, 42, 42)

Here is the call graph for this function:

Definition at line 134 of file buffer_tests.py.

00134 
00135     def test_swapcase(self):
00136         self.assertEqual(b'hEllO CoMPuTErS',
00137             self.marshal(b'HeLLo cOmpUteRs').swapcase())
00138 
00139         self.assertRaises(TypeError, self.marshal(b'hello').swapcase, 42)

Here is the call graph for this function:

Definition at line 179 of file buffer_tests.py.

00179 
00180     def test_title(self):
00181         self.assertEqual(b' Hello ', self.marshal(b' hello ').title())
00182         self.assertEqual(b'Hello ', self.marshal(b'hello ').title())
00183         self.assertEqual(b'Hello ', self.marshal(b'Hello ').title())
00184         self.assertEqual(b'Format This As Title String',
00185                          self.marshal(b'fOrMaT thIs aS titLe String').title())
00186         self.assertEqual(b'Format,This-As*Title;String',
00187                          self.marshal(b'fOrMaT,thIs-aS*titLe;String').title())
00188         self.assertEqual(b'Getint', self.marshal(b'getInt').title())
00189         self.assertRaises(TypeError, self.marshal(b'hello').title, 42)

Here is the call graph for this function:

Definition at line 96 of file buffer_tests.py.

00096 
00097     def test_upper(self):
00098         self.assertEqual(b'HELLO', self.marshal(b'HeLLo').upper())
00099         self.assertEqual(b'HELLO', self.marshal(b'HELLO').upper())
00100         self.assertRaises(TypeError, self.marshal(b'hello').upper, 42)

Here is the call graph for this function:

Definition at line 140 of file buffer_tests.py.

00140 
00141     def test_zfill(self):
00142         self.assertEqual(b'123', self.marshal(b'123').zfill(2))
00143         self.assertEqual(b'123', self.marshal(b'123').zfill(3))
00144         self.assertEqual(b'0123', self.marshal(b'123').zfill(4))
00145         self.assertEqual(b'+123', self.marshal(b'+123').zfill(3))
00146         self.assertEqual(b'+123', self.marshal(b'+123').zfill(4))
00147         self.assertEqual(b'+0123', self.marshal(b'+123').zfill(5))
00148         self.assertEqual(b'-123', self.marshal(b'-123').zfill(3))
00149         self.assertEqual(b'-123', self.marshal(b'-123').zfill(4))
00150         self.assertEqual(b'-0123', self.marshal(b'-123').zfill(5))
00151         self.assertEqual(b'000', self.marshal(b'').zfill(3))
00152         self.assertEqual(b'34', self.marshal(b'34').zfill(1))
00153         self.assertEqual(b'0034', self.marshal(b'34').zfill(4))
00154 
00155         self.assertRaises(TypeError, self.marshal(b'123').zfill)

Here is the call graph for this function:


Member Data Documentation

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


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