Allowing using ephemeral ports for testing with Screen #4792
Replies: 2 comments 4 replies
-
Thanks for bringing this up @drcraig. You can already configure the port by simply calling nicegui/nicegui/native/native_mode.py Lines 123 to 136 in 5bd08f9 We could set |
Beta Was this translation helpful? Give feedback.
-
I think in the case of tests passing port |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The
Screen
class for testing currently hard-codes the port number to 3392. This makes it challenging to run a testsuite that tests multiple different nicegui apps in parallel. A solution for this could be to allow (or even default to) using ephemeral ports, by settingScreen.PORT
to 0 and letting the operating system assign an ephemeral port.I don't have a strong opinion on whether Screen should default to using an ephemeral port vs. that being an option. I could see allowing the port to be an init argument of
Screen
, and then bubbling that setting up through thescreen
fixture and its dependencies so that the user could set it. Perhaps the port number could be a fixture that the user could override.For this to work, there would also need to be a change to
ui.run
, which check the falsiness of the port argument when deciding whether to use the port argument or default to 8080. This prevents passing a port of zero.I'd be happy to help contribute this change.
Beta Was this translation helpful? Give feedback.
All reactions