Skip to content

Commit 5a1eb00

Browse files
jorwoodsjacalata
authored andcommitted
chore: pytestify models repr (#1684)
* fix: black ci errors * chore: pytestify models repr --------- Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent 6184715 commit 5a1eb00

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

test/models/test_repr.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import inspect
22
from typing import Any
3-
from test.models._models import get_unimplemented_models
3+
4+
import _models # type: ignore # did not set types for this
45
import tableauserverclient as TSC
56

67
import pytest
@@ -45,4 +46,18 @@ def try_instantiate_class(name: str, obj: Any) -> Any | None:
4546
return instance
4647
else:
4748
print(f"Class '{name}' does not have a constructor (__init__ method).")
48-
return None
49+
50+
51+
def is_concrete(obj: Any):
52+
return inspect.isclass(obj) and not inspect.isabstract(obj)
53+
54+
55+
@pytest.mark.parametrize("class_name, obj", inspect.getmembers(TSC, is_concrete))
56+
def test_by_reflection(class_name, obj):
57+
instantiate_class(class_name, obj)
58+
59+
60+
@pytest.mark.parametrize("model", _models.get_defined_models())
61+
def test_repr_is_implemented(model):
62+
print(model.__name__, type(model.__repr__).__name__)
63+
assert type(model.__repr__).__name__ == "function"

0 commit comments

Comments
 (0)