Skip to content

Commit b976b71

Browse files
committed
don't try to reach into home dirs in tests
1 parent b65ff41 commit b976b71

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

qbpm/operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def from_session(
3030
def launch(
3131
profile: Profile, create: bool, foreground: bool, qb_args: tuple[str, ...]
3232
) -> bool:
33-
if not profiles.ensure_profile_exists(profile, create):
33+
if not profiles.ensure_profile_exists(profile, create, desktop_file=True):
3434
return False
3535

3636
args = profile.cmdline() + list(qb_args)

qbpm/profiles.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ def create_desktop_file(profile: Profile) -> None:
5757
desktop.write()
5858

5959

60-
def ensure_profile_exists(profile: Profile, create: bool = True) -> bool:
60+
def ensure_profile_exists(
61+
profile: Profile, create: bool = True, desktop_file: bool = False
62+
) -> bool:
6163
if profile.root.exists() and not profile.root.is_dir():
6264
error(f"{profile.root} is not a directory")
6365
return False
6466
if not profile.root.exists() and create:
65-
return new_profile(profile)
67+
return new_profile(profile, desktop_file=desktop_file)
6668
if not profile.root.exists():
6769
error(f"{profile.root} does not exist")
6870
return False

tests/test_main.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
from qbpm.main import main
77

8+
no_desktop = "--no-desktop-file"
9+
810

911
def test_profile_dir_option(tmp_path: Path):
1012
(tmp_path / "config.py").touch()
1113
runner = CliRunner()
1214
result = runner.invoke(
13-
main, ["-C", str(tmp_path), "-P", str(tmp_path), "new", "test"]
15+
main, ["-C", str(tmp_path), "-P", str(tmp_path), "new", no_desktop, "test"]
1416
)
1517
assert result.exit_code == 0
1618
assert result.output.strip() == str(tmp_path / "test")
@@ -21,7 +23,7 @@ def test_profile_dir_env(tmp_path: Path):
2123
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
2224
(tmp_path / "config.py").touch()
2325
runner = CliRunner()
24-
result = runner.invoke(main, ["-C", str(tmp_path), "new", "test"])
26+
result = runner.invoke(main, ["-C", str(tmp_path), "new", no_desktop, "test"])
2527
assert result.exit_code == 0
2628
assert result.output.strip() == str(tmp_path / "test")
2729
assert tmp_path / "test" in list(tmp_path.iterdir())
@@ -32,7 +34,7 @@ def test_config_dir_option(tmp_path: Path):
3234
config = tmp_path / "config.py"
3335
config.touch()
3436
runner = CliRunner()
35-
result = runner.invoke(main, ["-C", str(tmp_path), "new", "test"])
37+
result = runner.invoke(main, ["-C", str(tmp_path), "new", no_desktop, "test"])
3638
assert result.exit_code == 0
3739
assert str(config) in (tmp_path / "test/config/config.py").read_text()
3840

@@ -43,7 +45,7 @@ def test_relative_config_dir(tmp_path: Path):
4345
config.touch()
4446
chdir(tmp_path)
4547
runner = CliRunner()
46-
result = runner.invoke(main, ["-C", ".", "new", "test"])
48+
result = runner.invoke(main, ["-C", ".", "new", no_desktop, "test"])
4749
assert result.exit_code == 0
4850
assert str(config) in (tmp_path / "test/config/config.py").read_text()
4951

@@ -54,7 +56,9 @@ def test_from_session(tmp_path: Path):
5456
session = tmp_path / "test.yml"
5557
session.write_text("windows:\n")
5658
runner = CliRunner()
57-
result = runner.invoke(main, ["-C", str(tmp_path), "from-session", str(session)])
59+
result = runner.invoke(
60+
main, ["-C", str(tmp_path), "from-session", no_desktop, str(session)]
61+
)
5862
assert result.exit_code == 0
5963
assert result.output.strip() == str(tmp_path / "test")
6064
assert (tmp_path / "test/data/sessions/_autosave.yml").read_text() == ("windows:\n")

tests/test_profiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,5 @@ def test_ensure_profile_exists_create(tmp_path: Path):
106106
def test_new_profile(tmp_path: Path):
107107
(tmp_path / "config.py").touch()
108108
profile = Profile("test", tmp_path / "test", tmp_path)
109-
assert profiles.new_profile(profile)
109+
assert profiles.new_profile(profile, desktop_file=False)
110110
check_new_profile(profile)

0 commit comments

Comments
 (0)