File: conftest.py

package info (click to toggle)
python-dogpile.cache 0.5.7-2~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 432 kB
  • sloc: python: 2,968; makefile: 100
file content (26 lines) | stat: -rw-r--r-- 667 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from _pytest.unittest import UnitTestCase
import sys


def is_unittest(obj):
    """Is obj a subclass of unittest.TestCase?

    Lifted from older versions of py.test, as this seems to be removed.

    """
    unittest = sys.modules.get('unittest')
    if unittest is None:
        return  # nobody can have derived unittest.TestCase
    try:
        return issubclass(obj, unittest.TestCase)
    except KeyboardInterrupt:
        raise
    except:
        return False


def pytest_pycollect_makeitem(collector, name, obj):
    if is_unittest(obj) and not obj.__name__.startswith("_"):
        return UnitTestCase(name, parent=collector)
    else:
        return []