Skip to content

Commit 398d9e6

Browse files
Fix: Ensure Mode.interactive is default in CI environment
Co-Authored-By: [email protected] <[email protected]>
1 parent 1a569b4 commit 398d9e6

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

.github/workflows/python-ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
else
6060
. ../../.venv/bin/activate
6161
fi
62+
unset SELFIE || true
6263
python -m pytest -vv
6364
6465
- name: selfie-lib - pyright
@@ -104,6 +105,7 @@ jobs:
104105
else
105106
. ../../.venv/bin/activate
106107
fi
108+
unset SELFIE || true
107109
python -m pytest -vv
108110
109111
- name: pytest-selfie - pyright
@@ -149,6 +151,7 @@ jobs:
149151
else
150152
. ../../.venv/bin/activate
151153
fi
154+
unset SELFIE || true
152155
python -m pytest -vv
153156
154157
- name: example-pytest-selfie - pyright

python/pytest-selfie/pytest_selfie/SelfieSettingsAPI.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ def root_folder(self) -> Path:
2828
return self.root_dir
2929

3030
def calc_mode(self) -> Mode:
31-
override = os.getenv("selfie") or os.getenv("SELFIE") # noqa: SIM112
32-
if override:
33-
# Convert the mode to lowercase and match it with the Mode enum
31+
selfie_env = os.getenv("selfie") or os.getenv("SELFIE") # noqa: SIM112
32+
if selfie_env:
33+
# Only use env var if explicitly set to "readonly"
34+
if selfie_env.lower() == "readonly":
35+
return Mode.readonly
3436
try:
35-
return Mode[override.lower()]
37+
# For backward compatibility, try to match other mode names
38+
return Mode[selfie_env.lower()]
3639
except KeyError:
37-
raise ValueError(f"No such mode: {override}") from None
40+
raise ValueError(f"No such mode: {selfie_env}") from None
3841

39-
ci = os.getenv("ci") or os.getenv("CI") # noqa: SIM112
40-
if ci and ci.lower() == "true":
41-
return Mode.readonly
42-
else:
43-
return Mode.interactive
42+
# Default to interactive mode when no environment variables are set
43+
return Mode.interactive
4444

4545

4646
class SelfieSettingsSmuggleError(SelfieSettingsAPI):

0 commit comments

Comments
 (0)