xonsh/tests/test_man.py
Noorhteen Raja NJ 38295a1dd9
Remove globals (#4280)
* refactor: remove usage of global variables in abbrevs.py

* chore: add flake8-mutable to prevent mutable defaults

* fix: abbrevs expand test

* refactor: add xonsh session singleton

* refactor: fix circular errors when using xonshSession as singleton

* refactor: remove black magicked builtin attributes

* style: black format tests as well

* refactor: update tests to use xonsh-session singleton

* refactor: update abbrevs to not use builtins

* test: remove DummyCommandsCache and patch orig class

* fix: failing test_command_completers

* test: use monkeypatch to update xession fixture

* fix: failing test_pipelines

* fix: failing test_main

* chore: run test suit as single invocation

* test: fix tests/test_xonsh.xsh

* refactor: remove builtins from docs/conf.py

* fix: mypy error in jobs

* fix: test error from test_main

* test: close xession error in test_command_completers

* chore: use pytest-cov for reporting coverage

this will include subprocess calls, and will increase coverage

* style:
2021-05-20 13:14:26 +03:00

28 lines
770 B
Python

# -*- coding: utf-8 -*-
import os
import pytest # noqa F401
from xonsh.completers.man import complete_from_man
from tools import skip_if_on_windows
from xonsh.parsers.completion_context import (
CompletionContext,
CommandContext,
CommandArg,
)
@skip_if_on_windows
def test_man_completion(monkeypatch, tmpdir, xession):
tempdir = tmpdir.mkdir("test_man")
monkeypatch.setitem(
os.environ, "MANPATH", os.path.dirname(os.path.abspath(__file__))
)
xession.env.update({"XONSH_DATA_DIR": str(tempdir)})
completions = complete_from_man(
CompletionContext(
CommandContext(args=(CommandArg("yes"),), arg_index=1, prefix="--")
)
)
assert "--version" in completions
assert "--help" in completions