dash icon indicating copy to clipboard operation
dash copied to clipboard

pytest plugin should not be registered by default

Open vfilimonov opened this issue 6 years ago • 5 comments

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.

vfilimonov avatar Sep 29 '19 20:09 vfilimonov

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?

alexcjohnson avatar Sep 30 '19 00:09 alexcjohnson

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

nylocx avatar Nov 15 '19 07:11 nylocx

@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.

byronz avatar Nov 15 '19 17:11 byronz

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.

gatesn avatar Jan 22 '21 11:01 gatesn

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].

jlf-incom avatar Jun 20 '22 08:06 jlf-incom

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.

radusuciu avatar Feb 08 '23 00:02 radusuciu