File: test_internal.py

package info (click to toggle)
python-polyfactory 2.22.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,892 kB
  • sloc: python: 11,338; makefile: 103; sh: 37
file content (27 lines) | stat: -rw-r--r-- 698 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
27
from polyfactory.utils._internal import is_attribute_overridden


class BaseClass:
    base_attr = "base_value"


class ChildClass(BaseClass):
    base_attr = "child_value"


class GrandChildClass(ChildClass):
    pass


class NonOverriddenClass(BaseClass):
    """A class that does not override the base attribute."""


def test_is_attribute_overridden() -> None:
    """Test the is_attribute_overridden function."""
    assert is_attribute_overridden(BaseClass, ChildClass, "base_attr")
    assert is_attribute_overridden(BaseClass, GrandChildClass, "base_attr")


def test_is_attribute_not_overridden() -> None:
    assert not is_attribute_overridden(BaseClass, NonOverriddenClass, "base_attr")