import sys from pathlib import Path import pytest from streamlit.testing.v1 import AppTest sys.path.append(str(Path(__file__).parent.parent)) def test_text_no_input(): at = AppTest.from_file("app.py").run() at.button[0].click().run() assert at.warning[0].value == "入力が空です。何か入力してください。" def test_text_with_input(): at = AppTest.from_file("app.py").run() # at.text_input[0].assert_exists() at.text_input[0].input("test").run() at.button[0].click().run() assert "判定結果: **マイクロアグレッションで" in at.markdown[2].value @pytest.mark.skip(reason="まだ実装していないのでランダムに返ってくる") def test_aggression(): at = AppTest.from_file("app.py").run() text = "サンプルの入力文字列NHKの番組を見ていると,発達障害者の才能を特集されることが多い。それを見ていると自分もそのような才能を期待されているように感じる" at.text_input[0].input(text).run() at.button[0].click().run() assert "提供元: " not in at.markdown[3].value