File: test_new_parser.py

package info (click to toggle)
python-libnmap 0.7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,416 kB
  • sloc: xml: 5,572; python: 4,299; makefile: 149
file content (38 lines) | stat: -rw-r--r-- 895 bytes parent folder | download
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)