saving-willy-dev / src /apptest /demo_whale_viewer.py
vancauwe's picture
fix: adapt tests to refactor and explicit module names
8963e74
# a minimal snippet for the whale viewer, for testing purposes
# - using AppTest to validate that the display_whale functionality
# is ok
# - currently placed in the src directory (not optimal) because
# I couldn't get pytest to pick it up from the tests directory.
# - TODO: find a cleaner solution for organisation (maybe just config to pytest?)
import streamlit as st
# to run streamlit from this subdir, we need the the src dir on the path
# NOTE: pytest doesn't need this to run the tests, but to develop the test
# harness is hard without running streamlit
import sys
from os import path
# src (parent from here)
src_dir = path.dirname( path.dirname( path.abspath(__file__) ) )
sys.path.append(src_dir)
import whale_viewer as whale_viewer
# a menu to pick one of the images
title = st.title("Whale Viewer testing")
species = st.selectbox("Species", whale_viewer.WHALE_CLASSES)
if species is not None:
# and display the image + reference
st.write(f"Selected species: {species}")
whale_viewer.display_whale([species], 0, st)