On Tue, Feb 27, 2024 at 10:22 PM Jeremy Spewock <jspew...@iol.unh.edu> wrote:
>
> <snip>
> > +
> > +        lowercase_suite_to_find = (
> > +            f"{self._test_suite_class_prefix}{module_name.replace('_', 
> > '')}".lower()
> > +        )
> > +        for class_name, class_obj in inspect.getmembers(test_suite_module, 
> > is_test_suite):
> > +            if (
> > +                class_name.startswith(self._test_suite_class_prefix)
>
> Is this line required? When we check later if the
> lowercase_suite_to_find is equal, we know that this variable we made
> starts with the designated prefix because that's just how we made it.
> It seems redundant because they could not be equal if the class name
> didn't start with the prefix. Is the idea behind this a type of
> optimization because this makes us ignore anything that doesn't have
> the proper prefix before going further?
>

There is a slight difference. The
class_name.startswith(self._test_suite_class_prefix) condition checks
uppercase characters as well. I'm not sure it's actually worth it.

Maybe we could change the name check to also check for the CamelCase
convention. I'll look into that.

> >
> > +                and lowercase_suite_to_find == class_name.lower()
> > +            ):
> > +                return class_obj
> > +        raise ConfigurationError(
> > +            f"Couldn't find any valid test suites in 
> > {test_suite_module.__name__}."
> > +        )
> <snip>

Reply via email to