mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
test: speedup test suit by reusing costly vars (#4384)
* test: speedup test suit by reusing costly vars * chore: revert changes to xonsh_execer fixture * revert changes to test_parser
This commit is contained in:
parent
e3db8b6621
commit
8831aca57f
2 changed files with 21 additions and 6 deletions
|
@ -66,14 +66,25 @@ def xonsh_events():
|
|||
setattr(events, name, newevent)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def session_vars():
|
||||
"""keep costly vars per session"""
|
||||
from xonsh.environ import Env, default_env
|
||||
from xonsh.commands_cache import CommandsCache
|
||||
|
||||
return {
|
||||
"execer": Execer(unload=False),
|
||||
"env": Env(default_env()),
|
||||
"commands_cache": CommandsCache(),
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def xonsh_builtins(monkeypatch, xonsh_events):
|
||||
def xonsh_builtins(monkeypatch, xonsh_events, session_vars):
|
||||
"""Mock out most of the builtins xonsh attributes."""
|
||||
old_builtins = set(dir(builtins))
|
||||
XSH.load(
|
||||
execer=Execer(unload=False),
|
||||
ctx={},
|
||||
)
|
||||
|
||||
XSH.load(ctx={}, **session_vars)
|
||||
if ON_WINDOWS:
|
||||
XSH.env["PATHEXT"] = [".EXE", ".BAT", ".CMD"]
|
||||
|
||||
|
|
|
@ -580,7 +580,11 @@ class XonshSession:
|
|||
self.subproc_captured_hiddenobject = subproc_captured_hiddenobject
|
||||
self.subproc_uncaptured = subproc_uncaptured
|
||||
self.execer = execer
|
||||
self.commands_cache = CommandsCache()
|
||||
self.commands_cache = (
|
||||
kwargs.pop("commands_cache")
|
||||
if "commands_cache" in kwargs
|
||||
else CommandsCache()
|
||||
)
|
||||
self.all_jobs = {}
|
||||
self.ensure_list_of_strs = ensure_list_of_strs
|
||||
self.list_of_strs_or_callables = list_of_strs_or_callables
|
||||
|
|
Loading…
Add table
Reference in a new issue