You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote some custom Input widgets. Unfortunately, testing them is really really slow.
Typing in a simple text like This is my text! needs ~15 seconds on my machine. I increasingly think about removing those test. But, of cause this would lead to other issues ... Could you please improve the execution time?
Example: performance_issue_app.py
importcProfileimportpstatsimportunittestimportpytestfromtextual.appimportApp, ComposeResultfromtextual.pilotimportPilotfromtextual.widgetsimportInputclassPerformanceIssueApp(App):
defcompose(self) ->ComposeResult:
yieldInput().focus()
classPerformanceIssueAppTest(unittest.IsolatedAsyncioTestCase):
asyncdeftest_type_text(self):
app=PerformanceIssueApp()
asyncwithapp.run_test() aspilot: # type:Pilotawaitpilot.press(*[cforcin"This is my text!"])
input_widget=pilot.app.query_exactly_one(Input)
self.assertEqual("This is my text!", input_widget.value)
if__name__=="__main__":
withcProfile.Profile() aspr:
try:
pytest.main(["-v", __file__])
finally:
pstats.Stats(pr).sort_stats(pstats.SortKey.CUMULATIVE).print_stats(50)
I'm not so familiar with unittest, but this test only takes a second to run on my machine just using pytest along with the pytest-asyncio plugin:
fromtextual.appimportApp, ComposeResultfromtextual.widgetsimportInputclassPerformanceIssueApp(App):
defcompose(self) ->ComposeResult:
yieldInput()
asyncdeftest_type_text() ->None:
app=PerformanceIssueApp()
asyncwithapp.run_test() aspilot:
awaitpilot.press(*"This is my text!")
input_widget=pilot.app.query_exactly_one(Input)
assertinput_widget.value=="This is my text!"
I wrote some custom Input widgets. Unfortunately, testing them is really really slow.
Typing in a simple text like
This is my text!
needs ~15 seconds on my machine. I increasingly think about removing those test. But, of cause this would lead to other issues ... Could you please improve the execution time?Example:
performance_issue_app.py
Output:
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: