From 1472b6c0304d2d232a91c12af40f313d1a39c055 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sat, 25 Feb 2017 07:53:16 -0800 Subject: [PATCH] Reformat new test and add comment header --- test/test_stab.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/test_stab.py b/test/test_stab.py index 83067b8..7180b2a 100644 --- a/test/test_stab.py +++ b/test/test_stab.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------------- +# elftools tests +# +# Eli Bendersky (eliben@gmail.com) +# This code is in the public domain +#------------------------------------------------------------------------------- try: import unittest2 as unittest except ImportError: @@ -8,13 +14,13 @@ 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), - ] + ("another label", 0x41, 0x66, 0xf9b1, 0xcafebabe)] with open(os.path.join('test', 'testfiles_for_unittests', 'obj_stabs.elf'), 'rb') as f: elf = ELFFile(f) @@ -22,17 +28,18 @@ class TestStab(unittest.TestCase): # using correct type? for s in elf.iter_sections(): if s.name == '.stab': - self.assertIsInstance (s, StabSection) + 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]) + 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() -- 2.30.2