コード例 #1
0
ファイル: test_compat.py プロジェクト: atlant2011/samba
 def test_encoding_is_cached(self):
     """The encoding should stay the same if the cache isn't invalidated"""
     self.put_source(
         "# coding: iso-8859-13\n"
         "import os\n")
     self.assertEquals("iso-8859-13", _get_source_encoding(self.filename))
     self.put_source(
         "# coding: rot-13\n"
         "vzcbeg bf\n")
     self.assertEquals("iso-8859-13", _get_source_encoding(self.filename))
コード例 #2
0
 def test_encoding_is_cached(self):
     """The encoding should stay the same if the cache isn't invalidated"""
     self.put_source(
         "# coding: iso-8859-13\n"
         "import os\n")
     self.assertEquals("iso-8859-13", _get_source_encoding(self.filename))
     self.put_source(
         "# coding: rot-13\n"
         "vzcbeg bf\n")
     self.assertEquals("iso-8859-13", _get_source_encoding(self.filename))
コード例 #3
0
 def test_traceback_rechecks_encoding(self):
     """A traceback function checks the cache and resets the encoding"""
     self.put_source("# coding: iso-8859-8\n" "import os\n")
     self.assertEquals("iso-8859-8", _get_source_encoding(self.filename))
     self.put_source("# coding: utf-8\n" "import os\n")
     try:
         exec(compile("raise RuntimeError\n", self.filename, "exec"))
     except RuntimeError:
         traceback.extract_tb(sys.exc_info()[2])
     else:
         self.fail("RuntimeError not raised")
     self.assertEquals("utf-8", _get_source_encoding(self.filename))
コード例 #4
0
ファイル: test_compat.py プロジェクト: hef/samba
 def test_traceback_rechecks_encoding(self):
     """A traceback function checks the cache and resets the encoding"""
     self.put_source("# coding: iso-8859-8\n" "import os\n")
     self.assertEquals("iso-8859-8", _get_source_encoding(self.filename))
     self.put_source("# coding: utf-8\n" "import os\n")
     try:
         exec(compile("raise RuntimeError\n", self.filename, "exec"))
     except RuntimeError:
         traceback.extract_tb(sys.exc_info()[2])
     else:
         self.fail("RuntimeError not raised")
     self.assertEquals("utf-8", _get_source_encoding(self.filename))
コード例 #5
0
ファイル: test_compat.py プロジェクト: atlant2011/samba
 def test_nonexistant_file_as_ascii(self):
     """When file can't be found, the encoding should default to ascii"""
     self.assertEquals("ascii", _get_source_encoding(self.filename))
コード例 #6
0
 def test_nonexistent_file_as_ascii(self):
     """When file can't be found, the encoding should default to ascii"""
     self.assertEquals("ascii", _get_source_encoding(self.filename))