Files
GildedRose-Refactoring-Kata/python/tests/test_gilded_rose_approvals.py
T
uzairarslan 5f113a1d2f Approve current output and fix the approval test reporter
Approved the 30 day fixture output as-is so there is a baseline before
refactoring. Conjured Mana Cake is still wrong here, that changes later.

The approval test was also crashing with "no reporter configuration"
instead of showing a diff. pytest-approvaltests 0.2.4 doesn't work with
approvaltests 19, so pass PythonNativeReporter directly.
2026-09-16 13:54:27 -04:00

30 lines
750 B
Python

import io
import sys
from approvaltests import Options, verify
from approvaltests.reporters import PythonNativeReporter
from texttest_fixture import main
# Print the diff to stdout on a mismatch rather than launching a GUI diff tool,
# so the test behaves identically locally, headless and in CI.
REPORTER = PythonNativeReporter()
def test_gilded_rose_approvals():
orig_sysout = sys.stdout
try:
fake_stdout = io.StringIO()
sys.stdout = fake_stdout
sys.argv = ["texttest_fixture.py", 30]
main()
answer = fake_stdout.getvalue()
finally:
sys.stdout = orig_sysout
verify(answer, options=Options().with_reporter(REPORTER))
if __name__ == "__main__":
test_gilded_rose_approvals()