Achieve 100% coverage!
This commit is contained in:
parent
52a2c800b7
commit
f49aa5cab7
@ -22,7 +22,6 @@ def _parse_xml(full_path: str):
|
|||||||
def parse_map(f): # etree support for ns is a bit rough
|
def parse_map(f): # etree support for ns is a bit rough
|
||||||
ns_map = dict()
|
ns_map = dict()
|
||||||
for event, (k, v) in ET.iterparse(f, ("start-ns", )):
|
for event, (k, v) in ET.iterparse(f, ("start-ns", )):
|
||||||
if event == "start-ns":
|
|
||||||
ns_map[k] = v
|
ns_map[k] = v
|
||||||
return ns_map
|
return ns_map
|
||||||
|
|
||||||
@ -166,7 +165,7 @@ class MSOfficeParser(ArchiveBasedAbstractParser):
|
|||||||
|
|
||||||
elements = list()
|
elements = list()
|
||||||
for element in tree.iterfind('.//w:ins', ns):
|
for element in tree.iterfind('.//w:ins', ns):
|
||||||
for position, item in enumerate(tree.iter()):
|
for position, item in enumerate(tree.iter()): #pragma: no cover
|
||||||
if item == element:
|
if item == element:
|
||||||
for children in element.iterfind('./*'):
|
for children in element.iterfind('./*'):
|
||||||
elements.append((element, position, children))
|
elements.append((element, position, children))
|
||||||
|
@ -69,9 +69,11 @@ class _BencodeHandler(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def __decode_string(s: bytes) -> Tuple[bytes, bytes]:
|
def __decode_string(s: bytes) -> Tuple[bytes, bytes]:
|
||||||
colon = s.index(b':')
|
colon = s.index(b':')
|
||||||
str_len = int(s[:colon])
|
# FIXME Python3 is broken here, the call to `ord` shouldn't be needed,
|
||||||
if s[0] == '0' and colon != 1:
|
# but apparently it is. This is utterly idiotic.
|
||||||
|
if (s[0] == ord('0') or s[0] == '0') and colon != 1:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
str_len = int(s[:colon])
|
||||||
s = s[1:]
|
s = s[1:]
|
||||||
return s[colon:colon+str_len], s[colon+str_len:]
|
return s[colon:colon+str_len], s[colon+str_len:]
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class TestCorruptedFiles(unittest.TestCase):
|
|||||||
torrent.TorrentParser('./tests/data/clean.torrent')
|
torrent.TorrentParser('./tests/data/clean.torrent')
|
||||||
|
|
||||||
with open("./tests/data/clean.torrent", "w") as f:
|
with open("./tests/data/clean.torrent", "w") as f:
|
||||||
f.write("d01:AAAAAAAAA")
|
f.write("01:AAAAAAAAA")
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
torrent.TorrentParser('./tests/data/clean.torrent')
|
torrent.TorrentParser('./tests/data/clean.torrent')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user