Mostly borrowed from argcomplete's unit test fixtures Set up environment variables to mimic those passed by argcomplete
(self, mocker)
| 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, |