Skip to content

Commit

Permalink
Add unit tests to diagnose issues #48
Browse files Browse the repository at this point in the history
  • Loading branch information
tantale committed Aug 25, 2021
1 parent 09c3151 commit aaca116
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/test_sphinx_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,68 @@ class MySubClass(MyBaseClass):
assert isinstance(obj, MyBaseClass)
assert inspect.isclass(MyBaseClass)
assert issubclass(MySubClass, MyBaseClass)


@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_isinstance_versionadded():
# https://github.com/tantale/deprecated/issues/48
@deprecated.sphinx.versionadded(version="X.Y", reason="some reason")
class VersionAddedCls:
pass

@deprecated.sphinx.versionadded(version="X.Y", reason="some reason")
class VersionAddedChildCls(VersionAddedCls):
pass

instance = VersionAddedChildCls()
assert isinstance(instance, VersionAddedChildCls)
assert isinstance(instance, VersionAddedCls)


@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_isinstance_versionchanged():
@deprecated.sphinx.versionchanged(version="X.Y", reason="some reason")
class VersionChangedCls:
pass

@deprecated.sphinx.versionchanged(version="X.Y", reason="some reason")
class VersionChangedChildCls(VersionChangedCls):
pass

instance = VersionChangedChildCls()
assert isinstance(instance, VersionChangedChildCls)
assert isinstance(instance, VersionChangedCls)


@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_isinstance_deprecated():
@deprecated.sphinx.deprecated(version="X.Y", reason="some reason")
class DeprecatedCls:
pass

@deprecated.sphinx.deprecated(version="Y.Z", reason="some reason")
class DeprecatedChildCls(DeprecatedCls):
pass

instance = DeprecatedChildCls()
assert isinstance(instance, DeprecatedChildCls)
assert isinstance(instance, DeprecatedCls)


@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_isinstance_versionadded_versionchanged():
@deprecated.sphinx.versionadded(version="X.Y")
@deprecated.sphinx.versionchanged(version="X.Y.Z")
class AddedChangedCls:
pass

instance = AddedChangedCls()
assert isinstance(instance, AddedChangedCls)

0 comments on commit aaca116

Please sign in to comment.