question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make sure we treat tests differently

See original GitHub issue

When 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:open
  • Created 4 years ago
  • Reactions:2
  • Comments:17 (15 by maintainers)

github_iconTop GitHub Comments

3reactions
skarzicommented, Feb 24, 2020

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 them
2reactions
sobolevncommented, Mar 22, 2020

Might 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.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found