-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the test screen implementation to allow customizable ports #3997
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request, @engineerjames!
After having another look at your proposed changes, we have some concerns:
- Renaming
PORT
toDEFAULT_PORT
can be considered a breaking change. Therefore we'd prefer to keep the namePORT
unchanged. - You added
self.ui_run_kwargs.update(kwargs)
to thestart_server
method. Why is this necessary? - How to you actually use the new
port
parameter? Thescreen
fixture doesn't allow to change it. And to change the port in Docker environments you could simply change the staticPORT
without using the new parameter.
Of course! These are great questions.
That is a fair point--happy to revert that.
I thought it would be a useful addition, but I'm also happy to revert that part of the MR if you all feel it isn't a good idea.
Unfortunately our current setup doesn't allow us to use Docker--for the use of the port parameter I was envisioning something like: from nicegui.testing import Screen
@pytest.fixture(scope='function')
def screen_fixture(caplog: pytest.LogCaptureFixture):
yield Screen(selenium.webdriver.Chrome(...), caplog, port=your_port_here)
def test_loading_ui(screen_fixture: Screen) -> None:
# Your test details here I'm still fairly new to Python though, so I may have overlooked some easier options to accomplish this. |
I think this has almost nothing to do with Docker (except that in a container you may have different ports then on your main machine). https://github.com/zauberzeug/nicegui/blob/main/nicegui/testing/screen_plugin.py#L67-L85 I'm still not sure how you would make multiple tests run in parallel. It would be great if you could provide the implementation in a pull request which builds on this one. |
Another thought regarding your custom @pytest.fixture(scope='function')
def screen_fixture(caplog: pytest.LogCaptureFixture):
Screen.PORT = 1234
yield Screen(selenium.webdriver.Chrome(...), caplog) |
Unfortunately this won't work because the default port is used in the constructor to set other member variables that are used in the implementation. :( |
I just reverted the renaming and the kwargs. The remaining change is
Now let's come back to my proposal: @pytest.fixture(scope='function')
def screen_fixture(caplog: pytest.LogCaptureFixture):
Screen.PORT = 1234
yield Screen(selenium.webdriver.Chrome(...), caplog)
I don't understand. If To be clear, I'm just trying to understand the benefit of the new |
My apologies it took me so long to get back to you all; I was on a business trip. Oh! I hadn't realized that setting |
This merge request adds the capability to customize the ports that the test
Screen
implementation uses. This allows for running multiple selenium-backed tests in parallel, and also allows users who aren't able to run in a container (and may be using this port for other things).Admittedly I was having some issues running the unit tests that I am still working on, but I wanted to get the code change out there to see what the community thought.