def test_pwd_tracks_cwd(xonsh_builtins, xonsh_execer, tmpdir_factory, monkeypatch ): asubdir = str(tmpdir_factory.mktemp("asubdir")) cur_wd = os.getcwd() xonsh_builtins.__xonsh_env__ = Env(PWD=cur_wd, XONSH_CACHE_SCRIPTS=False, XONSH_CACHE_EVERYTHING=False) monkeypatch.setattr(xonsh_execer, "cacheall", False, raising=False) bc = BaseShell(xonsh_execer, None) assert os.getcwd() == cur_wd bc.default('os.chdir(r"' + asubdir + '")') assert os.path.abspath(os.getcwd()) == os.path.abspath(asubdir) assert os.path.abspath(os.getcwd()) == os.path.abspath(xonsh_builtins.__xonsh_env__['PWD']) assert 'OLDPWD' in xonsh_builtins.__xonsh_env__ assert os.path.abspath(cur_wd) == os.path.abspath(xonsh_builtins.__xonsh_env__['OLDPWD'])
def test_pwd_tracks_cwd(xession, xonsh_execer, tmpdir_factory, monkeypatch): asubdir = str(tmpdir_factory.mktemp("asubdir")) cur_wd = os.getcwd() xession.env.update( dict(PWD=cur_wd, XONSH_CACHE_SCRIPTS=False, XONSH_CACHE_EVERYTHING=False) ) monkeypatch.setattr(xonsh_execer, "cacheall", False, raising=False) bc = BaseShell(xonsh_execer, None) assert os.getcwd() == cur_wd bc.default('os.chdir(r"' + asubdir + '")') assert os.path.abspath(os.getcwd()) == os.path.abspath(asubdir) assert os.path.abspath(os.getcwd()) == os.path.abspath(xession.env["PWD"]) assert "OLDPWD" in xession.env assert os.path.abspath(cur_wd) == os.path.abspath(xession.env["OLDPWD"])
def __init__(self, completekey="tab", stdin=None, stdout=None, **kwargs): BaseShell.__init__(self, **kwargs) # super() doesn't pass the stdin/stdout to Cmd's init method correctly. # so calling it explicitly cmd.Cmd.__init__(self, completekey=completekey, stdin=stdin, stdout=stdout) setup_readline() self._current_indent = "" self._current_prompt = "" self._force_hide = None self._complete_only_last_table = { # Truth table for completions, keys are: # (prefix_begs_quote, prefix_ends_quote, i_ends_quote, # last_starts_with_prefix, i_has_space) (True, True, True, True, True): True, (True, True, True, True, False): True, (True, True, True, False, True): False, (True, True, True, False, False): True, (True, True, False, True, True): False, (True, True, False, True, False): False, (True, True, False, False, True): False, (True, True, False, False, False): False, (True, False, True, True, True): True, (True, False, True, True, False): False, (True, False, True, False, True): False, (True, False, True, False, False): True, (True, False, False, True, True): False, (True, False, False, True, False): False, (True, False, False, False, True): False, (True, False, False, False, False): False, (False, True, True, True, True): True, (False, True, True, True, False): True, (False, True, True, False, True): True, (False, True, True, False, False): True, (False, True, False, True, True): False, (False, True, False, True, False): False, (False, True, False, False, True): False, (False, True, False, False, False): False, (False, False, True, True, True): False, (False, False, True, True, False): False, (False, False, True, False, True): False, (False, False, True, False, False): True, (False, False, False, True, True): True, (False, False, False, True, False): False, (False, False, False, False, True): False, (False, False, False, False, False): False, } self.cmdqueue = collections.deque()