Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6242645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:59:33+00:00 2026-05-24T11:59:33+00:00

I usually unit test per class and this is no problem. However after messing

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:59:33+00:00Added an answer on May 24, 2026 at 11:59 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a unit test project based on UnitTest++. I usually put a breakpoint
Following on from this question...I'm trying to unit test the following scenario: I have
To be able to unit test my C++ code I usually pass the constructor
Usually when my regex patterns look like this: http://www.microsoft.com/ Then i have to escape
I have a lot of unit tests that pretty much tests the same behavior.
I am reviewing this technology but have a few design concerns that made me
How do you usually go about separating your codebase and associated unit tests ?
Usually when I need to fork in C, I do something like this: pid_t
Usually when defining a DAO, you would have a setter for the datasource on
In .NET should you place unit test projects in with the rest of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.