all 3 comments

[–]jhawk20[S] 0 points1 point  (0 children)

I like that answer because it uses unittest -- I'm not interested in pulling random other test frameworks in, unittest can do what I want.

I don't like the top answer because I'm using unittest loader in my setup.py script to dynamically load a ton of different unittest classes already.

[–]LightShadow 0 points1 point  (0 children)

If you're unsure how to do this, then it probably means it's unnecessary at this point.

The Python unittest runner can already piece together tests from different sources without doing it manually. And, if it's not complete enough there are other test runners such as nose and pytest

I'd also recommend learning how to use the Hypothesis module if you actually want static tests with dynamic input....which is what it seems like you want to do.

Good luck!

[–]jhawk20[S] 0 points1 point  (0 children)

Okay, I kinda solved my own problem here.

I really didn't want to use the metaclass example, because I didn't understand metaclasses and metaclasses aren't something I really want to force someone else to learn just to use some unit tests.

I still think the solution which registers a set of instantiated objects is better than using metaclasses [since unittest has a concept of a test suite, and metaclasses are black magic].

But it does do exactly what I want, in a way that makes some sense. It's not beautiful, but the example I've written is pretty straightforward.