Spaces:
Running
Running
rmm
commited on
Commit
·
eaa1c71
1
Parent(s):
00921cc
test: using src/apptest subdir for the test harnesses
Browse files- streamlit executes ok like this
- pytest executes ok like this
- couldn't get the same results from the tests directory unfortunately.
- src/__init__.py +0 -0
- src/{demo_wv.py → apptest/demo_wv.py} +11 -1
- tests/test_demo_wv.py +2 -2
src/__init__.py
ADDED
File without changes
|
src/{demo_wv.py → apptest/demo_wv.py}
RENAMED
@@ -6,8 +6,18 @@
|
|
6 |
# - TODO: find a cleaner solution for organisation (maybe just config to pytest?)
|
7 |
|
8 |
import streamlit as st
|
9 |
-
import whale_viewer as sw_wv
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# a menu to pick one of the images
|
13 |
title = st.title("Whale Viewer testing")
|
|
|
6 |
# - TODO: find a cleaner solution for organisation (maybe just config to pytest?)
|
7 |
|
8 |
import streamlit as st
|
|
|
9 |
|
10 |
+
# to run streamlit from this subdir, we need the the src dir on the path
|
11 |
+
# NOTE: pytest doesn't need this to run the tests, but to develop the test
|
12 |
+
# harness is hard without running streamlit
|
13 |
+
import sys
|
14 |
+
from os import path
|
15 |
+
# src (parent from here)
|
16 |
+
src_dir = path.dirname( path.dirname( path.abspath(__file__) ) )
|
17 |
+
sys.path.append(src_dir)
|
18 |
+
|
19 |
+
|
20 |
+
import whale_viewer as sw_wv
|
21 |
|
22 |
# a menu to pick one of the images
|
23 |
title = st.title("Whale Viewer testing")
|
tests/test_demo_wv.py
CHANGED
@@ -17,7 +17,7 @@ def test_selectbox_ok():
|
|
17 |
- finally, we check there are the right number of options (26)
|
18 |
|
19 |
'''
|
20 |
-
at = AppTest.from_file("src/demo_wv.py").run()
|
21 |
assert len(at.selectbox) == 1
|
22 |
assert at.selectbox[0].value == "beluga"
|
23 |
assert at.selectbox[0].index == 0
|
@@ -62,7 +62,7 @@ def test_img_props():
|
|
62 |
- then changing the image, we do the same checks again
|
63 |
|
64 |
'''
|
65 |
-
at = AppTest.from_file("src/demo_wv.py").run()
|
66 |
ix = 0 # we didn't interact with the dropdown, so it should be the first one
|
67 |
# could fetch the property - maybe better in case code example changes
|
68 |
ix = at.selectbox[0].index
|
|
|
17 |
- finally, we check there are the right number of options (26)
|
18 |
|
19 |
'''
|
20 |
+
at = AppTest.from_file("src/apptest/demo_wv.py").run()
|
21 |
assert len(at.selectbox) == 1
|
22 |
assert at.selectbox[0].value == "beluga"
|
23 |
assert at.selectbox[0].index == 0
|
|
|
62 |
- then changing the image, we do the same checks again
|
63 |
|
64 |
'''
|
65 |
+
at = AppTest.from_file("src/apptest/demo_wv.py").run()
|
66 |
ix = 0 # we didn't interact with the dropdown, so it should be the first one
|
67 |
# could fetch the property - maybe better in case code example changes
|
68 |
ix = at.selectbox[0].index
|