Exemple #1
0
    def test_utf16(self):
        """Test `utf-16` file."""

        self.compare_encoding(
            'utf16_be_bom.txt',
            codecs.BOM_UTF16_BE + 'UTF16BE file with BOM'.encode('utf-16-be'),
            td.Encoding('utf-16-be', codecs.BOM_UTF16_BE), 'utf-16-be')
Exemple #2
0
    def test_utf32(self):
        """Test `utf-8` file."""

        self.compare_encoding(
            'utf16_be_bom.txt',
            codecs.BOM_UTF32_BE + 'UTF32BE file with BOM'.encode('utf-32-be'),
            td.Encoding('utf-32-be', codecs.BOM_UTF32_BE), 'utf-32-be')
Exemple #3
0
    def test_wrong(self):
        """Test wrong encoding failure."""

        self.compare_encoding(
            'utf8.txt',
            'exámple'.encode('utf-8'),
            td.Encoding('utf-32-be', codecs.BOM_UTF32_BE),
            'bin'
        )
Exemple #4
0
    def test_utf8(self):
        """Test `utf-8` file."""

        self.compare_encoding(
            'utf8-bom.txt',
            'UTF8 file with BOM'.encode('utf-8-sig'),
            td.Encoding('utf-8', codecs.BOM_UTF8),
            'utf-8'
        )
Exemple #5
0
    def test_bin(self):
        """Test bin file."""

        self.compare_encoding(
            'binary.txt',
            b'This is a \x00\x00\x00binary test.\n',
            td.Encoding('bin', None),
            'bin'
        )
Exemple #6
0
    def test_string_unicode(self):
        """Test passing a binary string."""

        self.compare_encoding(
            'buffer',
            'test',
            td.Encoding('unicode', None),
            'unicode',
            True
        )
Exemple #7
0
    def test_string_bin(self):
        """Test passing a binary string."""

        self.compare_encoding(
            'buffer',
            b'test',
            td.Encoding('bin', None),
            'bin',
            True
        )
Exemple #8
0
    def test_bin_rummageexception(self):
        """Test `RummageException` with a bin file."""

        rfc = rc._RummageFileContent(self.norm('does_not_exist.txt'), 10,
                                     td.Encoding('bin', None))
        self.assertRaises(rc.RummageException, rfc.__enter__)