In a streamlit project, i have two pages and these two pages depends upon other moudules and these module contains several functions. one of the function i have mentioned below i.e
def delete_items(connection,id,db,schema, table):
col1, col2 = st.columns([0.1,1]) # Adjust the column widths as needed
with col1:
st.button("Yes",on_click=confirm_delete, args=[connection,id,db,schema, table])
with col2:
st.button("No",on_click=set_state, args=[0])
i am little confused that do i really need to test each and every function. if yes, how we can achieve it ?
for testing i tried
def test_delete_items():
' ' ' test wheather item is deleted ' ' '
app = AppTest.from_function(delete_items).run(timeout=5)
assert app.columns
# assert app.columns[0
assert 'Yes' in app.button[0].label
assert 'No' in app.button[1].label
however it failed. because the actual function takes some arguments and i am confusing how to ingest those arguments from the test file itself. i tried with *args to ingest arguments but also failed.
any kind of support would be highly appreciated.
cheers,
Swetansu
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.