Ejemplo n.º 1
0
def test_dunderscore_test_attribute():
    class SimpleCase(TestCase):
        pass

    class AbstractCase(TestCase):
        __test__ = False

    class NonAbstractCase(TestCase):
        __test__ = True

    assert is_test_class(SimpleCase)
    assert not is_test_class(AbstractCase)
    assert is_test_class(NonAbstractCase)
Ejemplo n.º 2
0
def pytest_pycollect_makeitem(collector, name, obj):
    """Override collection of Rotest classes.

    This returns instances of RotestTestWrapper where needed, and disregards
    classes that are abstract. Other objects (such as pytest test functions
    and old unittest classes) will be collected normally.
    """
    if isinstance(obj, type) and issubclass(obj, (TestSuite, AbstractTest)):
        if is_test_class(obj):
            return RotestTestWrapper.from_parent(collector, name=name)

        else:
            return []
Ejemplo n.º 3
0
def test_non_case_or_flow_are_not_test_classes():
    assert not is_test_class(unittest.TestCase)
    assert not is_test_class(TestSuite)
    assert not is_test_class(TestBlock)
Ejemplo n.º 4
0
def test_abstract_tests_are_not_test_classes():
    assert not is_test_class(TestCase)
Ejemplo n.º 5
0
def test_instance_is_not_test_class():
    assert not is_test_class(1)