Skip to content

Commit

Permalink
add no profile test for bash
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Jan 7, 2025
1 parent 07758d0 commit 26a36e2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/shellcompletion/test_bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,19 @@ def test_rich_output(self): ...
@pytest.mark.skipif(shutil.which("bash") is None, reason="Bash not available")
class BashExeTests(_InstalledScriptCompleteTestCase, BashTests):
shell = "bash"

@pytest.mark.skipif(
not bool(os.environ.get("ENABLE_CI_ONLY_TESTS", False)),
reason="This test is dangerous to run on a user machine, "
"because it may nuke their shell profile file.",
)
def test_no_bashrc_file(self):
bashrc = ""
try:
if (Path.home() / ".bashrc").exists():
bashrc = (Path.home() / ".bashrc").read_text()
os.unlink(Path.home() / ".bashrc")
self.test_shell_complete()
finally:
if bashrc:
(Path.home() / ".bashrc").write_text(bashrc)

0 comments on commit 26a36e2

Please sign in to comment.