Esempio n. 1
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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 4
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))
Esempio n. 5
0
 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))
Esempio n. 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))