Skip to content

fix: decode help-banner test subprocess output as UTF-8#2120

Merged
mashraf-222 merged 1 commit intomainfrom
fix/test-help-banner-windows-utf8
Apr 28, 2026
Merged

fix: decode help-banner test subprocess output as UTF-8#2120
mashraf-222 merged 1 commit intomainfrom
fix/test-help-banner-windows-utf8

Conversation

@mashraf-222
Copy link
Copy Markdown
Contributor

Problem

tests/test_help_banner.py has been failing on unit-tests (windows-latest, 3.13) since PR #2014 introduced it. CI on main is red — see https://github.com/codeflash-ai/codeflash/actions/runs/25056045918 and earlier. The failure is TypeError: argument of type 'NoneType' is not iterable at assert "codeflash.ai" in result.stdout.

Root Cause

print_codeflash_banner() renders a Rich Panel that contains box-drawing characters (, , , , etc.). The subprocess call uses subprocess.run(..., text=True) without an explicit encoding=. On Windows, text=True defaults to cp1252, which cannot decode those code points. Python's subprocess catches the UnicodeDecodeError internally and sets result.stdout = None, which is what surfaces as the confusing NoneType error at the assertion.

Fix

Pass encoding="utf-8" explicitly on both subprocess.run calls — matches the repo's existing code-style.md rule that requires encoding="utf-8" on open/read_text/write_text.

Validation

$ uv run pytest tests/test_help_banner.py -v
tests/test_help_banner.py::test_help_displays_logo PASSED         [ 50%]
tests/test_help_banner.py::test_help_short_flag_displays_logo PASSED [100%]

Tests were already passing on Linux (ubuntu-latest with default UTF-8 locale); the change does not regress them. This unblocks the required checks passed gate on PRs #1947, #1950, #1951, #1953, and every future PR touching anything in the unit-tests matrix.

Rich renders the banner panel with box-drawing characters (╭, ╮, │, etc.)
that cp1252 cannot decode. On Windows, subprocess.run(..., text=True) uses
cp1252 by default, so decoding the child stdout raises UnicodeDecodeError
and subprocess sets result.stdout to None — breaking the assertion with a
misleading "argument of type 'NoneType' is not iterable".

Pass encoding="utf-8" explicitly so the test passes on every platform.
@mashraf-222 mashraf-222 merged commit 1ba6af0 into main Apr 28, 2026
32 of 33 checks passed
@mashraf-222 mashraf-222 deleted the fix/test-help-banner-windows-utf8 branch April 28, 2026 17:04
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.

2 participants