Skip to content

Commit 98fbd60

Browse files
fix: only set BASIC_MEMORY_ENV=test during pytest runs (#482)
Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Paul Hernandez <[email protected]>
1 parent 6281a81 commit 98fbd60

File tree

1 file changed

+6
-2
lines changed
  • src/basic_memory/alembic

1 file changed

+6
-2
lines changed

src/basic_memory/alembic/env.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121

2222
from basic_memory.config import ConfigManager
2323

24-
# set config.env to "test" for pytest to prevent logging to file in utils.setup_logging()
25-
os.environ["BASIC_MEMORY_ENV"] = "test"
24+
# Trigger: only set test env when actually running under pytest
25+
# Why: alembic/env.py is imported during normal operations (MCP server startup, migrations)
26+
# but we only want test behavior during actual test runs
27+
# Outcome: prevents is_test_env from returning True in production, enabling watch service
28+
if os.getenv("PYTEST_CURRENT_TEST") is not None:
29+
os.environ["BASIC_MEMORY_ENV"] = "test"
2630

2731
# Import after setting environment variable # noqa: E402
2832
from basic_memory.models import Base # noqa: E402

0 commit comments

Comments
 (0)