plotly / dash

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

PytestDeprecationWarning: The hookimpl pytest_addhooks uses old-style configuration options #2420

Open johnkangw opened 1 year ago

johnkangw commented 1 year ago

Describe your context Please provide us your environment, so we can easily reproduce the issue.


**Describe the bug**

Pytest deprecation warning from the dash\testing\plugin.py

============================== warnings summary ===============================
..\..\.conda\envs\Capacity_venv\lib\site-packages\dash\testing\plugin.py:83
  C:\Users\JKANG1\.conda\envs\Capacity_venv\lib\site-packages\dash\testing\plugin.py:83: PytestDeprecationWarning: The hookimpl pytest_addhooks uses old-style configuration options (marks or attributes).
  Please use the pytest.hookimpl(tryfirst=True) decorator instead
   to configure the hooks.
   See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
    @pytest.mark.tryfirst
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

**Expected behavior**

No deprecation warning

**Screenshots**

![image](https://user-images.githubusercontent.com/72617548/218217696-93f874e1-6c9a-4db7-8457-63e8679ce840.png)
nickmelnikov82 commented 1 year ago

This issue is caused by an outdated way of configuring Hooks in the dash\testing\plugin.py file. To resolve this issue, you need to update the code in this file using the new way of configuring Hooks.

Update the dash\testing\plugin.py file by replacing the following line:

@pytest.mark.tryfirst

with

@pytest.hookimpl(tryfirst=True)

After making these changes, the deprecation messages should disappear and you should no longer receive deprecation warnings when running tests.

Be careful when editing the dash\testing\plugin.py file and make sure you save it with the correct changes. It is also recommended that you create a backup copy of the file before making changes so that you can revert to the original state if necessary.