You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pwndbg/tests/unit-tests/mocks/aglib.py

36 lines
1.0 KiB
Python

from __future__ import annotations
import sys
import types
from unittest.mock import MagicMock
from mocks.arch import Amd64Arch
from mocks.config import Config
from mocks.typeinfo import Amd64TypeInfo
class AgLib(types.ModuleType):
def __init__(self, module_name):
super().__init__(module_name)
self.config_mod = Config(module_name + ".config")
self.arch = Amd64Arch(module_name + ".arch")
self.typeinfo = Amd64TypeInfo(module_name + ".typeinfo")
self.regs = MagicMock(__name__=module_name + ".regs")
self.prompt = MagicMock(__name__=module_name + ".prompt")
sys.modules[self.config_mod.__name__] = self.config_mod
sys.modules[self.arch.__name__] = self.arch
sys.modules[self.typeinfo.__name__] = self.typeinfo
sys.modules[self.regs.__name__] = self.regs
sys.modules[self.prompt.__name__] = self.prompt
module_name = "pwndbg.aglib"
module = AgLib(module_name)
sys.modules[module_name] = module
import pwndbg
pwndbg.aglib = sys.modules["pwndbg.aglib"]