Skip to content

fix: tolerate log handlers without baseFilename (pytest compat) - #142

Open
afatihakpolat wants to merge 1 commit into
BusKill:devfrom
afatihakpolat:fix-131-log-handler-basefilename
Open

fix: tolerate log handlers without baseFilename (pytest compat)#142
afatihakpolat wants to merge 1 commit into
BusKill:devfrom
afatihakpolat:fix-131-log-handler-basefilename

Conversation

@afatihakpolat

Copy link
Copy Markdown

Closes #131

Bug

BusKill.init crashed under pytest with AttributeError: '_LiveLoggingNullHandler' object has no attribute 'baseFilename' at src/packages/buskill/init.py:227, because pytest replaces root handlers with its own (no baseFilename).

Fix

One line on dev: getattr fallback so handlers without baseFilename yield None instead of crash. Dev already guarded empty handlers list but not missing attribute; this strengthens it. Normal FileHandler path unchanged (real path preserved).

Before: logger.root.handlers[0].baseFilename if handlers else None -> AttributeError under pytest
After: getattr(handlers[0], 'baseFilename', None) if handlers else None -> None under pytest, real path normally

Tests

  • Repro instantiating BusKill under pytest: FAILED before (exact AttributeError), passes after (LOG_FILE_PATH None)
  • Edge: no handlers None, NullHandler None, StreamHandler None, FileHandler real path, mixed None no crash (5/5)
  • py_compile clean (pre-existing SyntaxWarnings only)
  • Note: LOG_FILE_PATH None only in test/embedded contexts; main.py always configures FileHandler so app unaffected. macOS root-child argv consumer noted.

Files

  • src/packages/buskill/init.py (1 line)

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.

1 participant