We’re currently working on an app testing framework and would love your feedback! This will make it dramatically easier to build automated tests for your app.
Extremely good feature. Looking forward to see an interface for auto deployment of applications such as st.deploy(github_config=“…”, file=“…”, branch=“…”)
Thanks Yeah we are looking at making programmatic deploy easier but I’m not sure about the timeline. I think we have discussed it more as happening through the CLI (like “streamlit deploy” similar to “streamlit run”) rather than through a new python API.
We want to improve the automation of our test harnesses and are currently using pytest (experimenting with Selenium). However, if we can use a native streamlit test suite and integrate that with our CICD (in my case via GitHub actions) then all the better!
Super looking forward to the stable production release of this test suite
I’m very exciting for this new feature.
It allows me to test streamlit application easily with pytest.
I’d like to share one of our use case, that in this time, we can’t test by this feature.
In our use case , to get who access application now, I create function in which I get header of WSS, like bellow.
_streamlit_version = re.search("(.+\..+)\..+",st.__version__).groups()[0] # 1.11.0 -> 1.11
if _streamlit_version <= "1.11": # streamkit version 1.11以前
from streamlit.server.server import Server
def _get_websocket_headers():
session_id = st.scriptrunner.get_script_run_ctx().session_id
session_info = Server.get_current()._session_info_by_id[session_id]
header = session_info.ws.request.headers
return header
elif _streamlit_version >= "1.14": # streamkit version 1.14以降
from streamlit.web.server.websocket_headers import _get_websocket_headers
else:
raise ImportError(f"Streamlit version:{st.__version__}は未対応です。")
※I understand this is very hackable way, but at now , there are no solucation to get user name in OSS streamlit ,like st.user in SiS or Community Cloud.
I’ll be very glad this feature support WSS, or achirve testable way to get user name.
When I tried this compnent, I met following error.
Runtime error :session client is not BrowserWebSocketHandler
Thank you @katsutoshi.ttm for the great feedback. I heard recently from a few people who are using this headers function so I want to look into whether we can add better explicit support, which would make it easier to test as well.
Just curious, is it possible to work around it with a mock patch, until we have a better solution? Something like this:
Thanks for this new App Test feature, really cool.
Is there a way to interact with st.file_uploader? Or a workaround ? I have an app where users need to upload a file and the if the content of the file is valid, a button will appear so they can do other stuff.
Hey @TheDigitilizer , I was playing around with this and trying to figure out if it’s possible. You can inspect that the widget renders and see some of the metadata settings by doing e.g.
fu = at.get("file_uploader")[0]
assert fu is not None
print(fu.proto) # inspect some properties
As best I can tell, there isn’t a way to set the value to a file with what we expose currently. Going to confirm with @AnOctopus. If that’s the case, will see if we can prioritize adding it before too long. Thanks!
Hi all, in case you are interested, we recently shipped a small GitHub Action to make it even easier to add tests to your apps and run them automatically.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.