Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when using fixtures but testing not installed. #2187

Merged
merged 4 commits into from
Aug 15, 2022

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Aug 9, 2022

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

@alexcjohnson
Copy link
Collaborator

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)?

@T4rk1n
Copy link
Contributor Author

T4rk1n commented Aug 9, 2022

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 =========================================

# Conflicts:
#	dash/testing/plugin.py
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃

@T4rk1n T4rk1n merged commit 495f794 into dev Aug 15, 2022
@T4rk1n T4rk1n deleted the testing-import-error branch August 15, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] dash.testing TypeError
2 participants