Back to index

python3.2  3.2.2
Public Member Functions
test.test_coding.CodingTest Class Reference

List of all members.

Public Member Functions

def test_bad_coding
def test_bad_coding2
def verify_bad_module
def test_exec_valid_coding
def test_file_parse
def test_error_from_string

Detailed Description

Definition at line 6 of file test_coding.py.


Member Function Documentation

Definition at line 7 of file test_coding.py.

00007 
00008     def test_bad_coding(self):
00009         module_name = 'bad_coding'
00010         self.verify_bad_module(module_name)

Here is the call graph for this function:

Definition at line 11 of file test_coding.py.

00011 
00012     def test_bad_coding2(self):
00013         module_name = 'bad_coding2'
00014         self.verify_bad_module(module_name)

Here is the call graph for this function:

Definition at line 51 of file test_coding.py.

00051 
00052     def test_error_from_string(self):
00053         # See http://bugs.python.org/issue6289
00054         input = "# coding: ascii\n\N{SNOWMAN}".encode('utf-8')
00055         with self.assertRaises(SyntaxError) as c:
00056             compile(input, "<string>", "exec")
00057         expected = "'ascii' codec can't decode byte 0xe2 in position 16: " \
00058                    "ordinal not in range(128)"
00059         self.assertTrue(c.exception.args[0].startswith(expected))
00060 

Here is the call graph for this function:

Definition at line 24 of file test_coding.py.

00024 
00025     def test_exec_valid_coding(self):
00026         d = {}
00027         exec('# coding: cp949\na = 5\n', d)
00028         self.assertEqual(d['a'], 5)

Here is the call graph for this function:

Definition at line 29 of file test_coding.py.

00029 
00030     def test_file_parse(self):
00031         # issue1134: all encodings outside latin-1 and utf-8 fail on
00032         # multiline strings and long lines (>512 columns)
00033         unload(TESTFN)
00034         sys.path.insert(0, os.curdir)
00035         filename = TESTFN + ".py"
00036         f = open(filename, "w")
00037         try:
00038             f.write("# -*- coding: cp1252 -*-\n")
00039             f.write("'''A short string\n")
00040             f.write("'''\n")
00041             f.write("'A very long string %s'\n" % ("X" * 1000))
00042             f.close()
00043 
00044             __import__(TESTFN)
00045         finally:
00046             f.close()
00047             unlink(filename)
00048             unlink(filename + "c")
00049             unload(TESTFN)
00050             del sys.path[0]

Here is the call graph for this function:

def test.test_coding.CodingTest.verify_bad_module (   self,
  module_name 
)

Definition at line 15 of file test_coding.py.

00015 
00016     def verify_bad_module(self, module_name):
00017         self.assertRaises(SyntaxError, __import__, 'test.' + module_name)
00018 
00019         path = os.path.dirname(__file__)
00020         filename = os.path.join(path, module_name + '.py')
00021         with open(filename, "rb") as fp:
00022             bytes = fp.read()
00023         self.assertRaises(SyntaxError, compile, bytes, filename, 'exec')

Here is the call graph for this function:

Here is the caller graph for this function:


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