I usually unit test per class and this is no problem. However after messing around with python I have hit a problem that I have not encountered before in other languages, meta classes and inner classes.
Say I have a class that contains an inner class and also has a meta class, what is the best way to structure unit tests for this situation?
One way could be to test all three in a single test module as they are so tightly coupled anyway. But this seems wrong to me. But how would I unit test the meta class on it's own, create a dummy class within the test that uses said meta class??
Your thoughts please stackoverflow!
You test a class by instantiating it. The "dummy class" you mentioned would be an instance of the metaclass, so that's exactly how you should test it.
When it comes to testing the inner class / outer class -- yes, I would include testing the inner class in the test for the outer class. If it makes sense to test the inner class independently from the outer class, why is it an inner class at all? Any inner class should only make sense in the scope of the outer class. If you are going to test it independently, you'll have to imitate the environment of the outer class anyway.
Unit testing metaclasses and inner classes in python