File: test_encoding.py

package info (click to toggle)
python-pyelftools 0.32-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,964 kB
  • sloc: python: 15,903; ansic: 298; asm: 86; makefile: 24; cpp: 18; sh: 4
file content (30 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# coding: utf-8
#-------------------------------------------------------------------------------
# elftools tests
#
# Audrey Dutcher (audrey@rhelmot.io)
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------

from __future__ import unicode_literals
import unittest
import os

from elftools.elf.elffile import ELFFile

class TestUnicodeSymbols(unittest.TestCase):
    """Test that we can handle a unicode symbol as produced by clang"""

    def test_delta(self):
        fname = os.path.join('test', 'testfiles_for_unittests',
                'unicode_symbols.elf')

        with open(fname, 'rb') as f:
            elf = ELFFile(f)
            symtab = elf.get_section_by_name('.symtab')
            list(symtab.iter_symbols()) # this used to just fail
            self.assertEqual(len(symtab.get_symbol_by_name('Δ')), 1)

if __name__ == '__main__':
    unittest.main()