Make sure we treat tests differently
See original GitHub issueWhen using pytest fixtures, you are supposed to just declare them as input arguments, and they will be automagically loaded. For example:
import pytest
from myapp import meaning_of_life
@pytest.fixture
def foo():
return 42
def test_meaning_of_life(foo):
meaning = meaning_of_life()
assert meaning == foo
This will violate rule 442, which is not desired in this case.
One could argue that fixtures should live on a different file than tests, but you run on the same issue if you have fixtures dependent on other fixtures:
import pytest
@pytest.fixture
def foo():
return 42
@pytest.fixture
def bar(foo):
return foo + 1
I think we need to make this feature “pytest aware”, or just document that it there is conflict with it and might need to be disabled.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:17 (15 by maintainers)
Top Results From Across the Web
8 tips for getting the best results from at-home COVID-19 ...
8. Confirm negative results with a PCR test. If you're experiencing symptoms and a rapid antigen test says you're positive, treat it as...
Read more >Test to Treat | HHS/ASPR
Information about the Test to Treat initiative, for people to get tested for COVID-19 and receive treatment, if appropriate, in one location.
Read more >Test Types & Their Strategies | Academic Success Center
Because they're designed to make sure you know the information, these tests often include more than just recognition, vocabulary, and knowledge-level questions; ...
Read more >Rapid coronavirus tests: a guide for the perplexed - Nature
David Harris, a stem-cell researcher in charge of Arizona's mass testing programme, says the different types of test have different uses: rapid ...
Read more >Repeating tests: different roles in research studies and clinical ...
Should the test be repeated for individual patients? ... The only reason to repeat tests in routine clinical practice is to prevent misclassification,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My
per-file-ignores
for tests includes violations mentioned by @sobolevn and additionally following one:WPS118
- imho test functions/methods should have nice, meaningful names, so it’s often better to use long but self-explanatory name for themMight be related: #1268
Maybe we can use some kind of
--tests-filename-pattern
(similar to http://doc.pytest.org/en/latest/reference.html#confval-python_files)? And disable some checks there by default?I don’t see much value in just updating the docs for this one. I suggest to add a feature that will solve this case.