Skip to content

Memory update from review of PR #19#20

Open
arcanist[bot] wants to merge 2 commits into
mainfrom
memory/update-from-pr-19
Open

Memory update from review of PR #19#20
arcanist[bot] wants to merge 2 commits into
mainfrom
memory/update-from-pr-19

Conversation

@arcanist
Copy link
Copy Markdown

@arcanist arcanist Bot commented Apr 20, 2026

Memory updates from PR #19

Add: Writing tests that need to mock a function imported with from x import y in the module under test.

Type: gotcha

Memory:

When testing Python code that does from module import func (a direct-reference import), patching module.func will NOT affect the already-imported reference. You must patch at the import site — e.g. patch nons.core.node.create_provider, not nons.utils.providers.create_provider. Alternatively, bypass provider creation entirely by patching node.execute directly on each instance.

Rationale:

The agent spent significant debugging effort discovering this. It initially patched nons.utils.providers.create_provider repeatedly in multiple test iterations, but this never worked because node.py holds a direct reference from its from ..utils.providers import create_provider import. The agent ultimately resolved it by patching node.execute on each instance instead. This is a non-obvious Python gotcha that wasted multiple test-run cycles.

Why this is a memory (not a convention update): This is a situational pattern that helps the agent in specific contexts, not a permanent rule for all future code.

Referenced files: nons/core/node.py, tests/test_layer.py, tests/test_node.py


Add: Setting up or debugging pytest configuration, especially when async tests fail with 'async def functions are not natively supported' despite asyncio_mode being set.

Type: gotcha

Memory:

In Python, a pytest.ini file must use [pytest] as its section header. Using [tool:pytest] (which is correct for setup.cfg) causes pytest to silently ignore all configuration, including asyncio_mode = auto. When pytest.ini exists, it takes precedence over pyproject.toml for pytest config — so a malformed pytest.ini blocks the pyproject.toml settings from being applied.

Rationale:

The agent discovered a pre-existing infrastructure bug: pytest.ini had [tool:pytest] instead of [pytest], which meant asyncio_mode = auto was never applied even though the setting existed in pyproject.toml as well. This caused 143+ async test failures that went undetected. Not obvious from reading the file — the header looks like valid INI syntax.

Why this is a memory (not a convention update): This is a situational pattern that helps the agent in specific contexts, not a permanent rule for all future code.

Referenced files: pytest.ini


Sessions: d55fa65f-1b03-461d-a5ab-9c4ce1f31a75

Merge to apply. Close to discard.

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.

0 participants