File: django_compat.py

package info (click to toggle)
pytest-django 4.11.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 604 kB
  • sloc: python: 4,006; makefile: 39; sh: 17
file content (17 lines) | stat: -rw-r--r-- 496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Note that all functions here assume django is available.  So ensure
# this is the case before you call them.
from __future__ import annotations

import pytest


def is_django_unittest(request_or_item: pytest.FixtureRequest | pytest.Item) -> bool:
    """Returns whether the request or item is a Django test case."""
    from django.test import SimpleTestCase

    cls = getattr(request_or_item, "cls", None)

    if cls is None:
        return False

    return issubclass(cls, SimpleTestCase)