Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_strlit.TestLiterals Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_template
def test_eval_str_normal
def test_eval_str_raw
def test_eval_bytes_normal
def test_eval_bytes_raw
def check_encoding
def test_file_utf_8
def test_file_utf_8_error
def test_file_utf8
def test_file_iso_8859_1
def test_file_latin_1
def test_file_latin9

Public Attributes

 save_path
 tmpdir

Detailed Description

Definition at line 59 of file test_strlit.py.


Member Function Documentation

def test.test_strlit.TestLiterals.check_encoding (   self,
  encoding,
  extra = "" 
)

Definition at line 112 of file test_strlit.py.

00112 
00113     def check_encoding(self, encoding, extra=""):
00114         modname = "xx_" + encoding.replace("-", "_")
00115         fn = os.path.join(self.tmpdir, modname + ".py")
00116         f = open(fn, "w", encoding=encoding)
00117         try:
00118             f.write(TEMPLATE % encoding)
00119             f.write(extra)
00120         finally:
00121             f.close()
00122         __import__(modname)
00123         del sys.modules[modname]

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 61 of file test_strlit.py.

00061 
00062     def setUp(self):
00063         self.save_path = sys.path[:]
00064         self.tmpdir = tempfile.mkdtemp()
00065         sys.path.insert(0, self.tmpdir)

Here is the caller graph for this function:

Definition at line 66 of file test_strlit.py.

00066 
00067     def tearDown(self):
00068         sys.path = self.save_path
00069         shutil.rmtree(self.tmpdir, ignore_errors=True)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 94 of file test_strlit.py.

00094 
00095     def test_eval_bytes_normal(self):
00096         self.assertEqual(eval(""" b'x' """), b'x')
00097         self.assertEqual(eval(r""" b'\x01' """), byte(1))
00098         self.assertEqual(eval(""" b'\x01' """), byte(1))
00099         self.assertEqual(eval(r""" b'\x81' """), byte(0x81))
00100         self.assertRaises(SyntaxError, eval, """ b'\x81' """)
00101         self.assertEqual(eval(r""" b'\u1881' """), b'\\' + b'u1881')
00102         self.assertRaises(SyntaxError, eval, """ b'\u1881' """)

Here is the call graph for this function:

Definition at line 103 of file test_strlit.py.

00103 
00104     def test_eval_bytes_raw(self):
00105         self.assertEqual(eval(""" br'x' """), b'x')
00106         self.assertEqual(eval(r""" br'\x01' """), b'\\' + b'x01')
00107         self.assertEqual(eval(""" br'\x01' """), byte(1))
00108         self.assertEqual(eval(r""" br'\x81' """), b"\\" + b"x81")
00109         self.assertRaises(SyntaxError, eval, """ br'\x81' """)
00110         self.assertEqual(eval(r""" br'\u1881' """), b"\\" + b"u1881")
00111         self.assertRaises(SyntaxError, eval, """ br'\u1881' """)

Here is the call graph for this function:

Definition at line 76 of file test_strlit.py.

00076 
00077     def test_eval_str_normal(self):
00078         self.assertEqual(eval(""" 'x' """), 'x')
00079         self.assertEqual(eval(r""" '\x01' """), chr(1))
00080         self.assertEqual(eval(""" '\x01' """), chr(1))
00081         self.assertEqual(eval(r""" '\x81' """), chr(0x81))
00082         self.assertEqual(eval(""" '\x81' """), chr(0x81))
00083         self.assertEqual(eval(r""" '\u1881' """), chr(0x1881))
00084         self.assertEqual(eval(""" '\u1881' """), chr(0x1881))

Here is the call graph for this function:

Definition at line 85 of file test_strlit.py.

00085 
00086     def test_eval_str_raw(self):
00087         self.assertEqual(eval(""" r'x' """), 'x')
00088         self.assertEqual(eval(r""" r'\x01' """), '\\' + 'x01')
00089         self.assertEqual(eval(""" r'\x01' """), chr(1))
00090         self.assertEqual(eval(r""" r'\x81' """), '\\' + 'x81')
00091         self.assertEqual(eval(""" r'\x81' """), chr(0x81))
00092         self.assertEqual(eval(r""" r'\u1881' """), '\\' + 'u1881')
00093         self.assertEqual(eval(""" r'\u1881' """), chr(0x1881))

Here is the call graph for this function:

Definition at line 135 of file test_strlit.py.

00135 
00136     def test_file_iso_8859_1(self):
00137         self.check_encoding("iso-8859-1")

Here is the call graph for this function:

Definition at line 141 of file test_strlit.py.

00141 
00142     def test_file_latin9(self):
00143         self.check_encoding("latin9")
00144 

Here is the call graph for this function:

Definition at line 138 of file test_strlit.py.

00138 
00139     def test_file_latin_1(self):
00140         self.check_encoding("latin-1")

Here is the call graph for this function:

Definition at line 132 of file test_strlit.py.

00132 
00133     def test_file_utf8(self):
00134         self.check_encoding("utf8")

Here is the call graph for this function:

Definition at line 124 of file test_strlit.py.

00124 
00125     def test_file_utf_8(self):
00126         extra = "z = '\u1234'; assert ord(z) == 0x1234\n"
00127         self.check_encoding("utf-8", extra)

Here is the call graph for this function:

Definition at line 128 of file test_strlit.py.

00128 
00129     def test_file_utf_8_error(self):
00130         extra = "b'\x80'\n"
00131         self.assertRaises(SyntaxError, self.check_encoding, "utf-8", extra)

Here is the call graph for this function:

Definition at line 70 of file test_strlit.py.

00070 
00071     def test_template(self):
00072         # Check that the template doesn't contain any non-printables
00073         # except for \n.
00074         for c in TEMPLATE:
00075             assert c == '\n' or ' ' <= c <= '~', repr(c)


Member Data Documentation

Definition at line 62 of file test_strlit.py.

Definition at line 63 of file test_strlit.py.


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