<commit_before>try:
    import unittest2 as unittest
except ImportError:
    import unittest
import os

from utils import setup_syspath; setup_syspath()
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import StabSection

class TestStab(unittest.TestCase):
    def test_stab(self):
        expected = [
            ("obj_stabs.S", 0, 0, 0x2, 33), # generated by compiler
            ("label", 0x95, 0xc8, 0x4072, 0xdeadbeef),
            ("another label", 0x41, 0x66, 0xf9b1, 0xcafebabe),
            ]
        with open(os.path.join('test', 'testfiles_for_unittests',
                               'obj_stabs.elf'), 'rb') as f:
            elf = ELFFile(f)

            # using correct type?
            for s in elf.iter_sections():
                if s.name == '.stab':
                    self.assertIsInstance (s, StabSection)

            # check section contents
            stab = elf.get_section_by_name('.stab')
            stabstr = elf.get_section_by_name('.stabstr')
            for entry, golden in zip (stab.iter_stabs (), expected):
                self.assertEqual(stabstr.get_string (entry.n_strx), golden[0])
                self.assertEqual(entry.n_type, golden[1])
                self.assertEqual(entry.n_other, golden[2])
                self.assertEqual(entry.n_desc, golden[3])
                self.assertEqual(entry.n_value, golden[4])

if __name__ == '__main__':
    unittest.main()<commit_msg>Reformat new test and add comment header<commit_after>#-------------------------------------------------------------------------------
# elftools tests
#
# <NAME> (<EMAIL>)
# This code is in the public domain
#-------------------------------------------------------------------------------
try:
    import unittest2 as unittest
except ImportError:
    import unittest
import os

from utils import setup_syspath; setup_syspath()
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import StabSection


class TestStab(unittest.TestCase):
    def test_stab(self):
        expected = [
            ("obj_stabs.S", 0, 0, 0x2, 33), # generated by compiler
            ("label", 0x95, 0xc8, 0x4072, 0xdeadbeef),
            ("another label", 0x41, 0x66, 0xf9b1, 0xcafebabe)]
        with open(os.path.join('test', 'testfiles_for_unittests',
                               'obj_stabs.elf'), 'rb') as f:
            elf = ELFFile(f)

            # using correct type?
            for s in elf.iter_sections():
                if s.name == '.stab':
                    self.assertIsInstance(s, StabSection)

            # check section contents
            stab = elf.get_section_by_name('.stab')
            stabstr = elf.get_section_by_name('.stabstr')
            for entry, golden in zip(stab.iter_stabs(), expected):
                self.assertEqual(stabstr.get_string(entry.n_strx), golden[0])
                self.assertEqual(entry.n_type, golden[1])
                self.assertEqual(entry.n_other, golden[2])
                self.assertEqual(entry.n_desc, golden[3])
                self.assertEqual(entry.n_value, golden[4])


if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.15564077980185362, 'fraction_numerical': 0.02109300095877277, 'mean_word_length': 1.9008341056533828, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '576178', 'n_tokens_mistral': 974, 'n_tokens_neox': 908, 'n_words': 212}