Skip to content

Conversation

rodja
Copy link
Member

@rodja rodja commented Oct 11, 2025

Motivation

We encourage devs to avoid the screen tests because they are slower and require Selenium to be installed. But the example in the docs uses the generic plugin which also requires Selenium.

Implementation

Updated demo to use non-selenium user-plugin. In the description above it is clearly explained that there are other plugins to pick. But the demo should be as simple as possible.

Progress

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • The implementation is complete.
  • Pytests are not necessary.
  • Documentation has been updated

@rodja rodja added this to the 3.1 milestone Oct 11, 2025
@rodja rodja requested a review from falkoschindler October 11, 2025 13:50
@rodja rodja added the review Status: PR is open and needs review label Oct 11, 2025
@rodja rodja changed the title use user_plugin in demo Suggest user_plugin in demo to avoid Selenium dependency Oct 11, 2025
@BayerSe
Copy link
Contributor

BayerSe commented Oct 13, 2025

This used to work for me in NiceGUI <3, but now it fails with below's message. I think this might be solved by moving the import of pytest_addoption from plugin.py to user_plugin.py and screen_plugin.py.

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/_pytest/main.py", line 289, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ~~~~^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/_pytest/main.py", line 342, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>     ~~~~~~~~~~~~~~^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/_pytest/logging.py", line 788, in pytest_collection
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>     ~~~~~~~~~~~~~~^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/_pytest/warnings.py", line 99, in pytest_collection
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 152, in _multicall
INTERNALERROR>     teardown.send(result)
INTERNALERROR>     ~~~~~~~~~~~~~^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1452, in pytest_collection
INTERNALERROR>     self._validate_config_options()
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1474, in _validate_config_options
INTERNALERROR>     self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1513, in _warn_or_fail_if_strict
INTERNALERROR>     self.issue_config_time_warning(PytestConfigWarning(message), stacklevel=3)
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/PycharmProjects/project/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1565, in issue_config_time_warning
INTERNALERROR>     warnings.warn(warning, stacklevel=stacklevel)
INTERNALERROR>     ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> pytest.PytestConfigWarning: Unknown config option: main_file

@BayerSe
Copy link
Contributor

BayerSe commented Oct 13, 2025

#5269 adds another function pytest_configure (to introduce the custom marker) that likely needs to be treated analogue to pytest_addoption

@rodja
Copy link
Member Author

rodja commented Oct 15, 2025

Thanks @BayerSe. I just added the import and verified behavior in a fresh venv. @falkoschindler you can review this together with #5269.

@falkoschindler falkoschindler added the testing Type/scope: Pytests and test fixtures label Oct 15, 2025
@falkoschindler falkoschindler merged commit cb72092 into main Oct 15, 2025
16 of 17 checks passed
@falkoschindler falkoschindler deleted the user_plugin-demo branch October 15, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review Status: PR is open and needs review testing Type/scope: Pytests and test fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants