Exemplo n.º 1
0
 def test_check_encoding_none(self):
     """Cases where the comparison fails."""
     # stream.encoding is None:
     self.assertEqual(io.check_encoding(io.FileInput(), 'ascii'), None)
     # stream.encoding does not exist:
     self.assertEqual(io.check_encoding(BBuf, 'ascii'), None)
     # encoding is None:
     self.assertEqual(io.check_encoding(mock_stdout, None), None)
     # encoding is invalid
     self.assertEqual(io.check_encoding(mock_stdout, 'UTF-9'), None)
Exemplo n.º 2
0
 def test_check_encoding_none(self):
     """Cases where the comparison fails."""
     # stream.encoding is None:
     self.assertEqual(io.check_encoding(io.FileInput(), 'ascii'), None)
     # stream.encoding does not exist:
     self.assertEqual(io.check_encoding(BBuf, 'ascii'), None)
     # encoding is None:
     self.assertEqual(io.check_encoding(mock_stdout, None), None)
     # encoding is invalid
     self.assertEqual(io.check_encoding(mock_stdout, 'UTF-9'), None)
Exemplo n.º 3
0
 def test_check_encoding_false(self):
     """Return `False` if lookup returns different codecs"""
     self.assertEqual(io.check_encoding(mock_stdout, 'ascii'), False)
     self.assertEqual(io.check_encoding(mock_stdout, 'latin-1'), False)
Exemplo n.º 4
0
 def test_check_encoding_true(self):
     """Return `True` if lookup returns the same codec"""
     self.assertEqual(io.check_encoding(mock_stdout, 'utf8'), True)
     self.assertEqual(io.check_encoding(mock_stdout, 'utf-8'), True)
     self.assertEqual(io.check_encoding(mock_stdout, 'UTF-8'), True)
Exemplo n.º 5
0
 def test_check_encoding_false(self):
     """Return `False` if lookup returns different codecs"""
     self.assertEqual(io.check_encoding(mock_stdout, 'ascii'), False)
     self.assertEqual(io.check_encoding(mock_stdout, 'latin-1'), False)
Exemplo n.º 6
0
 def test_check_encoding_true(self):
     """Return `True` if lookup returns the same codec"""
     self.assertEqual(io.check_encoding(mock_stdout, 'utf8'), True)
     self.assertEqual(io.check_encoding(mock_stdout, 'utf-8'), True)
     self.assertEqual(io.check_encoding(mock_stdout, 'UTF-8'), True)