Skip to content

Commit 92f4209

Browse files
committed
Reformat comments and a bit of test logic
1 parent a3f1b7c commit 92f4209

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

elftools/elf/dynamic.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,22 @@ class Dynamic(object):
7575
"""
7676
def __init__(self, stream, elffile, stringtable, position, empty):
7777
"""
78-
:param stream: The file-like object from which to load data
79-
:param elffile: The parent elffile object
80-
:param stringtable: A stringtable reference to use for parsing string references in entries
81-
:param position: The file offset of the dynamic segment/section
82-
:param empty: Whether this is a degenerate case with zero entries. Normally, every dynamic table
83-
will have at least one entry, the DT_NULL terminator.
78+
stream:
79+
The file-like object from which to load data
80+
81+
elffile:
82+
The parent elffile object
83+
84+
stringtable:
85+
A stringtable reference to use for parsing string references in
86+
entries
87+
88+
position:
89+
The file offset of the dynamic segment/section
90+
91+
empty:
92+
Whether this is a degenerate case with zero entries. Normally, every
93+
dynamic table will have at least one entry, the DT_NULL terminator.
8494
"""
8595
self.elffile = elffile
8696
self.elfstructs = elffile.structs

test/test_dbgfile.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,23 @@
99

1010
class TestDBGFile(unittest.TestCase):
1111
def test_dynamic_segment(self):
12-
"""
13-
Test that the degenerate case for the dynamic segment does not crash
12+
""" Test that the degenerate case for the dynamic segment does not crash
1413
"""
1514
with open(os.path.join('test', 'testfiles_for_unittests',
1615
'debug_info.elf'), 'rb') as f:
1716
elf = ELFFile(f)
1817

1918
seen_dynamic_segment = False
2019
for segment in elf.iter_segments():
21-
if segment.header.p_type != 'PT_DYNAMIC':
22-
continue
23-
24-
self.assertEqual(segment.num_tags(), 0, "The dynamic segment in this file should be empty")
25-
seen_dynamic_segment = True
26-
break
20+
if segment.header.p_type == 'PT_DYNAMIC':
21+
self.assertEqual(segment.num_tags(), 0, "The dynamic segment in this file should be empty")
22+
seen_dynamic_segment = True
23+
break
2724

2825
self.assertTrue(seen_dynamic_segment, "There should be a dynamic segment in this file")
2926

3027
def test_dynamic_section(self):
31-
"""
32-
Test that the degenerate case for the dynamic section does not crash
28+
""" Test that the degenerate case for the dynamic section does not crash
3329
"""
3430
with open(os.path.join('test', 'testfiles_for_unittests',
3531
'debug_info.elf'), 'rb') as f:
@@ -39,8 +35,7 @@ def test_dynamic_section(self):
3935
self.assertEqual(section.num_tags(), 0, "The dynamic section in this file should be empty")
4036

4137
def test_eh_frame(self):
42-
"""
43-
Test that parsing .eh_frame with SHT_NOBITS does not crash
38+
""" Test that parsing .eh_frame with SHT_NOBITS does not crash
4439
"""
4540
with open(os.path.join('test', 'testfiles_for_unittests',
4641
'debug_info.elf'), 'rb') as f:

0 commit comments

Comments
 (0)