Spaces:
Sleeping
Sleeping
added tests
Browse files- app.py +2 -2
- requirements-dev.txt +1 -0
- tests/__pycache__/test_app.cpython-311-pytest-8.1.1.pyc +0 -0
- tests/test_app.py +30 -0
app.py
CHANGED
@@ -29,9 +29,9 @@ st.markdown(explanation_text)
|
|
29 |
user_input = st.text_input("文章を入力してください:", key="user_input")
|
30 |
|
31 |
|
32 |
-
if st.button("判定"):
|
33 |
if not user_input:
|
34 |
-
st.
|
35 |
else:
|
36 |
st.markdown(attention_text)
|
37 |
st.divider()
|
|
|
29 |
user_input = st.text_input("文章を入力してください:", key="user_input")
|
30 |
|
31 |
|
32 |
+
if st.button("判定", key="run"):
|
33 |
if not user_input:
|
34 |
+
st.warning("入力が空です。何か入力してください。")
|
35 |
else:
|
36 |
st.markdown(attention_text)
|
37 |
st.divider()
|
requirements-dev.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
-r requirements.txt
|
2 |
ruff
|
3 |
mypy
|
|
|
|
1 |
-r requirements.txt
|
2 |
ruff
|
3 |
mypy
|
4 |
+
pytest
|
tests/__pycache__/test_app.cpython-311-pytest-8.1.1.pyc
ADDED
Binary file (4.87 kB). View file
|
|
tests/test_app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from pathlib import Path
|
3 |
+
|
4 |
+
import pytest
|
5 |
+
from streamlit.testing.v1 import AppTest
|
6 |
+
|
7 |
+
sys.path.append(str(Path(__file__).parent.parent))
|
8 |
+
|
9 |
+
|
10 |
+
def test_text_no_input():
|
11 |
+
at = AppTest.from_file("app.py").run()
|
12 |
+
at.button[0].click().run()
|
13 |
+
assert at.warning[0].value == "入力が空です。何か入力してください。"
|
14 |
+
|
15 |
+
|
16 |
+
def test_text_with_input():
|
17 |
+
at = AppTest.from_file("app.py").run()
|
18 |
+
# at.text_input[0].assert_exists()
|
19 |
+
at.text_input[0].input("test").run()
|
20 |
+
at.button[0].click().run()
|
21 |
+
assert "判定結果: **マイクロアグレッションで" in at.markdown[2].value
|
22 |
+
|
23 |
+
|
24 |
+
@pytest.mark.skip(reason="まだ実装していないのでランダムに返ってくる")
|
25 |
+
def test_aggression():
|
26 |
+
at = AppTest.from_file("app.py").run()
|
27 |
+
text = "サンプルの入力文字列NHKの番組を見ていると,発達障害者の才能を特集されることが多い。それを見ていると自分もそのような才能を期待されているように感じる"
|
28 |
+
at.text_input[0].input(text).run()
|
29 |
+
at.button[0].click().run()
|
30 |
+
assert "提供元: " not in at.markdown[3].value
|