def test_run_invalid_option(self, capsys): instance = pe.PE() instance.set_commandline(["invalid"]) instance.run() out, err = capsys.readouterr() assert re.search(r".*argument subname: invalid choice.*", out)
def test_run_short_help(self, capsys): instance = pe.PE() instance.set_commandline(["-h"]) instance.run() out, err = capsys.readouterr() assert re.search(r"^usage:.*", out)
def test_security(self, capsys, filename, expected): __sessions__.new(os.path.join(FIXTURE_DIR, filename)) instance = pe.PE() instance.command_line = ["security"] instance.run() out, err = capsys.readouterr() assert re.search(r".*{}*".format(expected), out)
def test_resources(self, capsys, filename, expected): __sessions__.new(os.path.join(FIXTURE_DIR, filename)) instance = pe.PE() instance.command_line = ["resources"] instance.run() out, err = capsys.readouterr() assert re.search(expected, expected)
def test_language(self, capsys, filename, expected): __sessions__.new(os.path.join(FIXTURE_DIR, filename)) instance = pe.PE() instance.command_line = ["language"] instance.run() out, err = capsys.readouterr() lines = out.split("\n") assert re.search(expected, lines[1])
def test_sections(self, capsys, filename, expected): __sessions__.new(os.path.join(FIXTURE_DIR, filename)) instance = pe.PE() instance.command_line = ["sections"] instance.run() out, err = capsys.readouterr() lines = out.split("\n") assert re.search(r".*Session opened*", lines[0]) assert re.search(r".*PE Sections.*", lines[1]) assert len(instance.result_sections) == expected
def test_compiletime(self, capsys, filename, expected): __sessions__.new(os.path.join(FIXTURE_DIR, filename)) instance = pe.PE() instance.command_line = ["compiletime"] instance.run() out, err = capsys.readouterr() lines = out.split("\n") assert re.search(r".*Session opened*", lines[0]) assert re.search(r".*Compile Time*", lines[1]) assert re.search(r".*{}*".format(expected), lines[1]) assert instance.result_compile_time == expected
def test_args_exception(self): instance = pe.PE() with pytest.raises(ArgumentErrorCallback) as excinfo: instance.parser.parse_args(["-h"]) excinfo.match(r".*Extract information from PE32 headers.*")
def test_init(self): instance = pe.PE() assert isinstance(instance, pe.PE) assert isinstance(instance, Module)