fix: only set BASIC_MEMORY_ENV=test during pytest runs by phernandez · Pull Request #482 · basicmachines-co/basic-memory · GitHub
Skip to content

fix: only set BASIC_MEMORY_ENV=test during pytest runs - #482

Merged
phernandez merged 1 commit into
mainfrom
claude/issue-481-20251229-1510
Dec 29, 2025
Merged

fix: only set BASIC_MEMORY_ENV=test during pytest runs#482
phernandez merged 1 commit into
mainfrom
claude/issue-481-20251229-1510

Conversation

@phernandez

Copy link
Copy Markdown
Member

Fixes #481

Problem

The alembic/env.py module was unconditionally setting BASIC_MEMORY_ENV='test' at import time, which caused config.is_test_env to always return True. This prevented the MCP server from starting the file watch service, breaking file sync for external changes.

Solution

Only set the env var when PYTEST_CURRENT_TEST is set, indicating an actual pytest run. This preserves test behavior while enabling watch service in production.

Testing

  • Tests remain safe because PYTEST_CURRENT_TEST is always set during pytest runs
  • tests/__init__.py also sets the env var for additional safety
  • config.is_test_env checks PYTEST_CURRENT_TEST directly as a third condition

———
Generated with Claude Code

The alembic/env.py module was unconditionally setting BASIC_MEMORY_ENV='test'
at import time, which caused config.is_test_env to always return True. This
prevented the MCP server from starting the file watch service, breaking file
sync for external changes.

Fix: Only set the env var when PYTEST_CURRENT_TEST is set, indicating an
actual pytest run. This preserves test behavior while enabling watch service
in production.

Fixes #481

Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

@phernandez
phernandez merged commit 98fbd60 into main Dec 29, 2025
20 checks passed
@phernandez
phernandez deleted the claude/issue-481-20251229-1510 branch December 29, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Broken file sync when using mcp

1 participant