From e91d23dd89daccd899309b67769a427e1f895736 Mon Sep 17 00:00:00 2001 From: Thor Whalen <1906276+thorwhalen@users.noreply.github.com> Date: Tue, 13 Oct 2026 07:11:15 +0000 Subject: [PATCH] Test: a failed submit keeps the selection (the old test never had a submit fail with a file selected) Co-Authored-By: Claude Opus 5.5 --- tests/test_file_uploader_clear.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_file_uploader_clear.py b/tests/test_file_uploader_clear.py index 15b6ef1..dfae42e 100644 --- a/tests/test_file_uploader_clear.py +++ b/tests/test_file_uploader_clear.py @@ -14,7 +14,7 @@ from streamlitfront.elements import FileUploader, MultiSourceInput, TextOutput def count_bytes(data: list) -> int: - if not data: + if not data or not sum(len(f.getvalue()) for f in data): raise ValueError("no data") st.info("drawn by the function") return sum(len(f.getvalue()) for f in data) @@ -87,9 +87,13 @@ def test_clear_after_submit_false_keeps_the_selection(): def test_failed_submit_keeps_the_selection(): - """The function raises on empty data; nothing was submitted, so nothing is cleared.""" + """A submit whose function raises submitted nothing, so nothing is cleared.""" at = _run_app() at.button[0].click().run() assert at.exception # ValueError from the function propagates, as before - at.file_uploader[0].upload("a.txt", b"").run() + at = _run_app() + at.file_uploader[0].upload("a.txt", b"").run() # selected, but empty: it raises + assert _names(at) == ["a.txt"] + at.button[0].click().run() + assert at.exception assert _names(at) == ["a.txt"]