plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.08k stars 2.04k forks source link

pytest plugin should not be registered by default #946

Closed vfilimonov closed 1 year ago

vfilimonov commented 4 years ago

Hello

I suggest that the pytest plugin should not be registered by default on dash installation.

A clean install of pytest without any plugins automatically activates dash-1.3.1 plugin (which increases the time of test suite by unnecessary import of the module and also annoys with the warning).

On a clean virtual environment:

$ python3 -m venv venv
$ source venv/bin/activate
$ pip install dash
$ pip install pytest
$ mkdir tests
$ cd tests/

an empty run of pytest results in

$ pytest
/Users/user/tmp/venv/lib/python3.7/site-packages/dash/testing/plugin.py:17: UserWarning:

run `pip install dash[testing]` if you need dash.testing

===================================================================== test session starts ======================================================================
platform darwin -- Python 3.7.1, pytest-5.2.0, py-1.8.0, pluggy-0.13.0
rootdir: /Users/user/tmp/tests
plugins: dash-1.3.1
collected 0 items                                                                                                                                              

==================================================================== no tests ran in 0.00s =====================================================================

Though the pytest-dash plugin was never installed:

$ pip uninstall pytest-dash
WARNING: Skipping pytest-dash as it is not installed.
alexcjohnson commented 4 years ago

Good point @vfilimonov - thanks for bringing it up, I think you're right that we only want the pytest plugin installed with dash[testing].

Unfortunately the solution isn't so clear to me. pytest-dash isn't used anymore, dash.testing is part of the main dash package now. So the pytest plugin is registered in the setup.py for dash itself, and it's not obvious to me how to supply entry points based on requested extras. This question was asked https://stackoverflow.com/questions/36005886/conditional-setuptools-entry-points, with no simple solutions given. Maybe @byronz will have some ideas when he's back from vacation?

nylocx commented 4 years ago

Hi, any news on that or at least way to disable the warning?

byronz commented 4 years ago

@nylocx @vfilimonov I will take a look at the issue, and find out a way for that. sorry for the delay, this was not on my radar before.

gatesn commented 3 years ago

Could we move all imports in dash/testing/plugin.py inside the fixtures themselves? This might delay the bulk of the imports until the fixtures are actually invoked.

jlf-incom commented 2 years ago

Any updates on this issue? We have a monorepo where dash is a dependency and we need to add some seleniumbase tests, but they have a conflict argument (--headless) that prevent us to do that. We are not using the plugin in dash[testing].

radusuciu commented 1 year ago

Any updates on this issue? We have a monorepo where dash is a dependency and we need to add some seleniumbase tests, but they have a conflict argument (--headless) that prevent us to do that. We are not using the plugin in dash[testing].

I have the same issue and just work around it like this:

sed -i 's/--headless/--headless_/g' /venv/lib/python3.9/site-packages/dash/testing/plugin.py

(called during container build time).

Alternatively, you can add -pno:dash as an argument when running pytest to disable the plugin altogether.