On Thu, Sep 5, 2024 at 4:07 AM Juraj Linkeš <juraj.lin...@pantheon.tech> wrote:
>
>
>
> On 26. 8. 2024 18:50, Jeremy Spewock wrote:
> > On Wed, Aug 21, 2024 at 10:53 AM Juraj Linkeš
> > <juraj.lin...@pantheon.tech> wrote:
> > <snip>
> >>   class DTSRunner:
> >> @@ -232,9 +231,9 @@ def _get_test_suites_with_cases(
> >>
> >>           for test_suite_config in test_suite_configs:
> >>               test_suite_class = 
> >> self._get_test_suite_class(test_suite_config.test_suite)
> >> -            test_cases = []
> >> -            func_test_cases, perf_test_cases = self._filter_test_cases(
> >> -                test_suite_class, test_suite_config.test_cases
> >> +            test_cases: list[type[TestCase]] = []
> >
> > If TestCase is just a class, why is the `type[]` in the annotation
> > required? Are these not specific instances of the TestCase class? I
> > figured they would need to be in order for you to run the specific
> > test case methods. Maybe this has something to do with the class being
> > a Protocol?
> >
>
> The *_test decorators return type[TestCase]. The functions (test
> methods) are cast to type[TestCase] (which kinda makes them subclasses
> of TestCase).

Oh interesting, I didn't make the connection that casting them to
type[TestCase] was similar to having them be subclasses of the type,
but this actually makes a lot of sense. Thank you for the
clarification!

>
> This was a suggestion from Luca and I took it as as. Maybe the functions
> could be cast as instances of TestCase, but I didn't try that.

Right, I would think that they could be cast directly to it, but
there's no need obviously so that makes sense.

>
> >> +            func_test_cases, perf_test_cases = 
> >> test_suite_class.get_test_cases(
> >> +                test_suite_config.test_cases
> >>               )
> >>               if func:
> >>                   test_cases.extend(func_test_cases)
<snip>
>

Reply via email to