MCPcopy Create free account
hub / github.com/ipython/traitlets / argcomplete_on

Method argcomplete_on

tests/config/test_argcomplete.py:76–96  ·  view source on GitHub ↗

Mostly borrowed from argcomplete's unit test fixtures Set up environment variables to mimic those passed by argcomplete

(self, mocker)

Source from the content-addressed store, hash-verified

74
75 @pytest.fixture()
76 def argcomplete_on(self, mocker):
77 """Mostly borrowed from argcomplete's unit test fixtures
78
79 Set up environment variables to mimic those passed by argcomplete
80 """
81 _old_environ = os.environ
82 os.environ = os.environ.copy() # type: ignore[assignment]
83 os.environ["_ARGCOMPLETE"] = "1"
84 os.environ["_ARC_DEBUG"] = "yes"
85 os.environ["IFS"] = self.IFS
86 os.environ["_ARGCOMPLETE_COMP_WORDBREAKS"] = self.COMP_WORDBREAKS
87
88 # argcomplete==2.0.0 always calls fdopen(9, "w") to open a debug stream,
89 # however this could conflict with file descriptors used by pytest
90 # and lead to obscure errors. Since we are not looking at debug stream
91 # in these tests, just mock this fdopen call out.
92 mocker.patch("os.fdopen")
93 try:
94 yield
95 finally:
96 os.environ = _old_environ
97
98 def run_completer(
99 self,

Callers

nothing calls this directly

Calls 1

copyMethod · 0.80

Tested by

no test coverage detected