From 10613091d3da1b178ed6dab8b006d1cb62756789 Mon Sep 17 00:00:00 2001 From: Jordan Woods <13803242+jorwoods@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:13:28 -0600 Subject: [PATCH 1/2] fix: black ci errors --- test/test_datasource.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_datasource.py b/test/test_datasource.py index 7f4cca75..56eb11ab 100644 --- a/test/test_datasource.py +++ b/test/test_datasource.py @@ -895,7 +895,8 @@ def test_publish_description(server: TSC.Server) -> None: ds_elem = body.find(".//datasource") assert ds_elem is not None assert ds_elem.attrib["description"] == "Sample description" - + + def test_get_datasource_no_owner(server: TSC.Server) -> None: with requests_mock.mock() as m: m.get(server.datasources.baseurl, text=GET_NO_OWNER.read_text()) From aa524ca4214db9a34ad43e53ca3a10ce902c3e35 Mon Sep 17 00:00:00 2001 From: Jordan Woods <13803242+jorwoods@users.noreply.github.com> Date: Fri, 7 Nov 2025 20:20:15 -0600 Subject: [PATCH 2/2] chore: pytestify models repr --- test/models/test_repr.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/test/models/test_repr.py b/test/models/test_repr.py index 92d11978..0f6057f4 100644 --- a/test/models/test_repr.py +++ b/test/models/test_repr.py @@ -1,10 +1,10 @@ import inspect +from typing import Any -from unittest import TestCase import _models # type: ignore # did not set types for this import tableauserverclient as TSC -from typing import Any +import pytest # ensure that all models that don't need parameters can be instantiated @@ -31,21 +31,16 @@ def instantiate_class(name: str, obj: Any): print(f"Class '{name}' does not have a constructor (__init__ method).") -class TestAllModels(TestCase): - # not all models have __repr__ yet: see above list - def test_repr_is_implemented(self): - m = _models.get_defined_models() - for model in m: - with self.subTest(model.__name__, model=model): - print(model.__name__, type(model.__repr__).__name__) - self.assertEqual(type(model.__repr__).__name__, "function") +def is_concrete(obj: Any): + return inspect.isclass(obj) and not inspect.isabstract(obj) - # 2 - Iterate through the objects in the module - def test_by_reflection(self): - for class_name, obj in inspect.getmembers(TSC, is_concrete): - with self.subTest(class_name, obj=obj): - instantiate_class(class_name, obj) +@pytest.mark.parametrize("class_name, obj", inspect.getmembers(TSC, is_concrete)) +def test_by_reflection(class_name, obj): + instantiate_class(class_name, obj) -def is_concrete(obj: Any): - return inspect.isclass(obj) and not inspect.isabstract(obj) + +@pytest.mark.parametrize("model", _models.get_defined_models()) +def test_repr_is_implemented(model): + print(model.__name__, type(model.__repr__).__name__) + assert type(model.__repr__).__name__ == "function"