dash icon indicating copy to clipboard operation
dash copied to clipboard

Improve error message when using fixtures but testing not installed.

Open T4rk1n opened this issue 3 years ago • 2 comments

Replace Any types in case dash[testing] was not installed but the fixtures used with a custom class that raise a proper error message.

Resolve #2183

T4rk1n avatar Aug 09 '22 16:08 T4rk1n

Nicely done! You've tested locally that this message shows up when you run pytest and try to use one of these fixtures without [testing] (but pytest still works if you don't try to use one of these fixtures)?

alexcjohnson avatar Aug 09 '22 16:08 alexcjohnson

Nicely done! You've tested locally that this message shows up when you run pytest and try to use one of these fixtures without [testing] (but pytest still works if you don't try to use one of these fixtures)?

Yes the exception is raised when trying to use a dash fixture:

 /repos/without_testing via  v3.9.5 (venv)
  pytest -k bsly001
======================================= test session starts ========================================
platform linux -- Python 3.9.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/philippe/repos/without_testing
plugins: dash-2.6.1
collected 1 item

test_without.py E                                                                            [100%]

============================================== ERRORS ==============================================
____________________________ ERROR at setup of test_bsly001_falsy_child ____________________________

    @pytest.fixture
    def dash_thread_server() -> ThreadedRunner:
        """Start a local dash server in a new thread."""
>       with ThreadedRunner() as starter:

../dash/dash/testing/plugin.py:117:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <dash.testing.plugin.MissingDashTesting object at 0x7f9224bb8be0>, kwargs = {}

    def __init__(self, **kwargs):
>       raise Exception(
            "dash[testing] was not installed. "
            "Please install to use the dash testing fixtures."
        )
E       Exception: dash[testing] was not installed. Please install to use the dash testing fixtures.

../dash/dash/testing/plugin.py:9: Exception
===================================== short test summary info ======================================
ERROR test_without.py::test_bsly001_falsy_child - Exception: dash[testing] was not installed. Ple...
========================================= 1 error in 0.02s =========================================

T4rk1n avatar Aug 09 '22 16:08 T4rk1n