jupyter_server: pytest fixture base_url conflict with pytest_base_url

Looks like this package now defines a pytest fixture named base_url that conflicts with another plugin https://pypi.org/project/pytest-base-url/ that defines the same fixture but with different scope

I started to get this error from a CI job here with the following logs:

ScopeMismatch: You tried to access the 'function' scoped fixture 'base_url' with a 'session' scoped request object, involved factories
../../../../__t/Python/3.8.6/x64/lib/python3.8/site-packages/pytest_base_url/plugin.py:19:  def _verify_url(request, base_url)
../../../../__t/Python/3.8.6/x64/lib/python3.8/site-packages/jupyter_server/pytest_plugin.py:205:  def base_url()

Not sure if there is a better way to fix this other than renaming the fixture here to something like jupyter_base_url.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for the heads up it totally fixed my issue. Thank you all!

@danielfrg, after a few iterations on our pytest plugin (and dependencies), Jupyter Server 1.1 was released with a new pytest plugin. All fixtures have been prefixed with jp_. The entrypoint for the plugin was removed so that pytest dependencies aren’t required for package installation.

To use this plugin for your extension, install the test dependencies of jupyter_server:

pip install jupyter_server[test]

then add the plugin to your conftest.py pytest_plugin variable:

# conftest.py
pytest_plugin = [
    "jupyter_server.pytest_plugin",
    ...
]

I’ll add this info to our documentation sometime today.

We discussed this our out last Jupyter Server meeting, @danielfrg.

We’re working on a separate pytest-plugin library, pytest-jupyter, that other projects (like yours) can use for testing. When I originally created the jupyter server plugin, I didn’t expect that it would be used outside this library. We’re learning now that it’s quite useful for extensions (e.g. jupyterlab, nbclassic, etc). This new plugin library will properly namespace fixtures (using a prefix) so there is little chance of fixture collisions. We should have this plugin released by the end of the week (hopefully sooner).

Thank you for the patience on this!