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 31 32 33 34 35 36 37 38
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from libnmap.parser import NmapParser, NmapParserException
baddatalist = [
"<host>aaa",
None,
"",
123,
"ports/>>>",
"<port<>",
"<port/>",
"<ports/aaaa>",
]
class TestNmapParser(unittest.TestCase):
def test_parse(self):
for baddata in baddatalist:
self.assertRaises(
NmapParserException, NmapParser.parse, baddata, "zz"
)
self.assertRaises(
NmapParserException, NmapParser.parse, baddata, "XML"
)
self.assertRaises(
NmapParserException, NmapParser.parse, baddata, "YAML"
)
if __name__ == "__main__":
test_suite = ["test_parse"]
suite = unittest.TestSuite(map(TestNmapParser, test_suite))
test_result = unittest.TextTestRunner(verbosity=2).run(suite)
|