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

PluginValidationError: unknown hook 'pytest_fixture_plus' #6475

Closed
smarie opened this issue Jan 16, 2020 · 7 comments
Closed

PluginValidationError: unknown hook 'pytest_fixture_plus' #6475

smarie opened this issue Jan 16, 2020 · 7 comments
Labels
type: question general question, might be closed after 2 weeks of inactivity

Comments

@smarie
Copy link
Contributor

smarie commented Jan 16, 2020

From smarie/python-pytest-cases#71

When the user writes from pytest_cases import pytest_fixture_plus in his conftest.py, the symbol is mistakenly thought as being a plugin hook by pytest, because the symbol name starts with pytest_.

My question is therefore simple: what is the recommended way to fix this issue in pytest_cases without renaming the symbol ?

@nicoddemus
Copy link
Member

My question is therefore simple: what is the recommended way to fix this issue in pytest_cases without renaming the symbol ?

I see you have provided of renaming the symbol in the issue... AFAIK there's no other workaround.

I guess it would be possible to add support in pluggy to somehow mark a symbol as "not a hook", but I'm not sure it is worth the effort, and this happens only in pytest for historical reasons: pluggy recommend marking hooks with the @hookimpl decorator instead of relying on the function prefix.

@nicoddemus nicoddemus added the type: question general question, might be closed after 2 weeks of inactivity label Jan 16, 2020
@nicoddemus
Copy link
Member

Closing for now, but feel free to follow up with further questions. 👍

@smarie
Copy link
Contributor Author

smarie commented Jan 17, 2020

It seems that I could decorate the symbols whose name starts with pytest_ with @pytest.hookimpl(optionalhook=True) to solve the issue.

Do you confirm that this would not have any other side effect ?

Note that would be very weird as these symbols are not hooks at all, they just have names starting with pytest_. But if it can solve the issue, I'll be happy to do it

@RonnyPfannschmidt
Copy link
Member

another simple fix is to use import ... as fixture_plus

@smarie
Copy link
Contributor Author

smarie commented Jan 17, 2020

Yes I had noted that one smarie/python-pytest-cases#71 (comment)

But the effort in on the users side, that's why I would prefer the @pytest.hookimpl(optionalhook=True) way (more dirty, but on my side).

If you feel this could work at least for a few versions, I can plan a name transition.

@RonnyPfannschmidt
Copy link
Member

as long as its also documented that this is a time bomb in the sense that its just waiting for someone to register a hook with that name

@RonnyPfannschmidt
Copy link
Member

lets open a pluggy issue for marking something as NOT A HOOK

smarie pushed a commit to smarie/python-pytest-cases that referenced this issue Jan 17, 2020
…xture_plus` and `pytest_parametrize_plus` were renamed to `fixture_plus` and `parametrize_plus` in order for pytest (pluggy) not to think they were hooks. Old aliases will stay around for a few versions, with a deprecation warning. See [#71](#71).
uhlajs added a commit to uhlajs/ma-gym that referenced this issue Sep 11, 2020
uhlajs added a commit to uhlajs/ma-gym that referenced this issue Sep 11, 2020
uhlajs added a commit to uhlajs/ma-gym that referenced this issue Sep 20, 2020
uhlajs added a commit to uhlajs/ma-gym that referenced this issue Sep 20, 2020
uhlajs added a commit to uhlajs/ma-gym that referenced this issue Sep 22, 2020
uhlajs added a commit to uhlajs/ma-gym that referenced this issue Oct 5, 2020
uhlajs added a commit to uhlajs/ma-gym that referenced this issue Oct 5, 2020
rapids-bot bot pushed a commit to rapidsai/cuml that referenced this issue Jun 2, 2023
This PR fixes a few separate warnings in pytests.

Examples:

```
../../../../../../opt/conda/envs/test/lib/python3.9/site-packages/hypothesis/_settings.py:467
  /opt/conda/envs/test/lib/python3.9/site-packages/hypothesis/_settings.py:467: HypothesisDeprecationWarning: `Healthcheck.all()` is deprecated; use `list(HealthCheck)` instead.
      The `hypothesis codemod` command-line tool can automatically refactor your code to fix this warning.
    note_deprecation(

../../../../../../opt/conda/envs/test/lib/python3.9/site-packages/cuml/internals/safe_imports.py:469
  /opt/conda/envs/test/lib/python3.9/site-packages/cuml/internals/safe_imports.py:469: DeprecationWarning: Please use `approx_fprime` from the `scipy.optimize` namespace, the `scipy.optimize.optimize` namespace is deprecated.
    return getattr(imported_module, symbol)

test_device_selection.py:192
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:192: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @pytest_fixture_plus(
```

Authors:
  - Bradley Dice (https://github.com/bdice)
  - Dante Gama Dessavre (https://github.com/dantegd)

Approvers:
  - AJ Schmidt (https://github.com/ajschmidt8)
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: #5436
rapids-bot bot pushed a commit to rapidsai/cuml that referenced this issue Mar 27, 2024
This PR fixes some warnings in tests by using `pytest_cases.fixture` instead of `pytest_cases.fixture_plus`.

```
test_device_selection.py:198
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:198: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:235
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:235: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:277
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:277: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:317
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:317: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:357
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:357: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:392
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:392: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:440
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:440: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:480
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:480: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:519
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:519: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(
```

Authors:
  - Bradley Dice (https://github.com/bdice)
  - Dante Gama Dessavre (https://github.com/dantegd)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: #5798
lijinf2 pushed a commit to lijinf2/cuml that referenced this issue Apr 2, 2024
This PR fixes some warnings in tests by using `pytest_cases.fixture` instead of `pytest_cases.fixture_plus`.

```
test_device_selection.py:198
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:198: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:235
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:235: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:277
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:277: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:317
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:317: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:357
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:357: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:392
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:392: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:440
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:440: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:480
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:480: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(

test_device_selection.py:519
  /__w/cuml/cuml/python/cuml/tests/test_device_selection.py:519: DeprecationWarning: `pytest_fixture_plus` and `fixture_plus` are deprecated. Please use the new alias `fixture`. See pytest-dev/pytest#6475
    @fixture_plus(
```

Authors:
  - Bradley Dice (https://github.com/bdice)
  - Dante Gama Dessavre (https://github.com/dantegd)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: rapidsai#5798
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants