def METHOD_NAME(self, module: ModuleType, post_check: Callable[[], None] | None = None) -> None:
    ''' Execute the configured source code in a module and run any post
    checks.
    Args:
        module (Module) :
            A module to execute the configured code in.
        post_check (callable, optional) :
            A function that raises an exception if expected post-conditions
            are not met after code execution.
    '''
    # Simulate the sys.path behaviour described here:
    #
    # https://docs.python.org/2/library/sys.html#sys.path
    _cwd = os.getcwd()
    _sys_path = list(sys.path)
    _sys_argv = list(sys.argv)
    sys.path.insert(0, os.path.dirname(self._path))
    sys.argv = [os.path.basename(self._path), *self._argv]
    # XXX: self._code shouldn't be None at this point but types don't reflect this
    assert self._code is not None
    try:
        exec(self._code, module.__dict__)
        if post_check:
            post_check()
    except Exception as e:
        handle_exception(self, e)
    finally:
        # undo sys.path, CWD fixups
        os.chdir(_cwd)
        sys.path = _sys_path
        sys.argv = _sys_argv
        self.ran = True