How run all the tests in a pytest test test class when the test class don't have test methods directly?

Answered
class TestNode:

class TestSetParent:
def test_1(self):
assert True

def test_2(self):
assert True

class TestGetParent:
def test_1(self):
assert True

def test_2(self):
assert True

In this case, there is no way to recognize that the entire file is a pytest file, and there is no way to recognize that the outermost class is actually executable.

Of course if you edit the configuration file manually, it is able to run either the whole file directly or that class.

1. Is this a BUG?

2. How do I all tests in the configuration file without manually editing the configuration file?

Of course, adding an irrelevant test method to that test class would solve this problem, which is not very good because it adds redundant and useless code.

1
2 comments

The module name should start with test for PyCharm to automatically consider it a test.
So renaming sd_test.py to test_sd.py should do the trick.

0
Avatar
Permanently deleted user

Hi Sergey Karpov,This is completely useless, because both ways of writing are compliant with the standard. Just in case, I still modified it as you requested, but the behavior is still exactly the same afterwards.

0

Please sign in to leave a comment.