title: unittest discover - Inherited test methods being executed twice
body: <p><strong>Situation 1</strong></p>
  
  <p>Suppose I have a test class that I'd like to re-use, <code>test_doubled.py</code>:</p>
  
  <pre><code>import unittest
  
  class BaseTestCase(unittest.TestCase):
      def test_something(self):
          self.assertTrue(True)
  </code></pre>
  
  <p>It contains a singled class, <code>BaseTestCase</code>, that inherits from <code>unittest.TestCase</code> and has a single test method.</p>
  
  <p>Running the test from the command line produces the following output as expected: </p>
  
  <pre><code>$ python -m unittest discover -p test_doubled.py -v
  test_something (test_doubled.BaseTestCase) ... ok
  
  ----------------------------------------------------------------------
  Ran 1 test in 0.000s
  
  OK
  </code></pre>
  
  <p><strong>Situation 2</strong></p>
  
  <p>Now suppose I add a second module, <code>test_doubled_2.py</code>, like so:</p>
  
  <pre><code>from test_doubled import BaseTestCase
  
  class DerivedTestCase(BaseTestCase):
      pass
  </code></pre>
  
  <p>It inherits from <code>BaseTestCase</code>, so I expect that it will have the same test method, and that the test method will get executed. However, when I run it, I get the following output:</p>
  
  <pre><code>$ python -m unittest discover -p test_doubled_2.py -v
  test_something (test_doubled.BaseTestCase) ... ok
  test_something (test_doubled_2.DerivedTestCase) ... ok
  
  ----------------------------------------------------------------------
  Ran 2 tests in 0.000s
  
  OK
  </code></pre>
  
  <p>It seems to run the method twice, once for the derived class, and once for the base class. This is not what I expect at all.</p>
  
  <p><strong>Situation 3</strong></p>
  
  <p>My suspicion is that, by importing <code>BaseTestCase</code> from <code>test_doubled_2.py</code>, the whole <code>BaseTestCase</code> class is getting executed. This seems to be confirmed by running both test modules:</p>
  
  <pre><code>$ python -m unittest discover -p test_doubled\*.py -v
  test_something (test_doubled.BaseTestCase) ... ok
  test_something (test_doubled.BaseTestCase) ... ok
  test_something (test_doubled_2.DerivedTestCase) ... ok
  
  ----------------------------------------------------------------------
  Ran 3 tests in 0.000s
  
  OK
  </code></pre>
  
  <p>Running both modules executes the same test method <em>three times</em>, when I would expect it to be executed only twice.</p>
  
  <p><strong>How can I get the test method to only execute once in Situation 2 and twice in Situation 3?</strong></p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>To clarify, the <code>BaseTestCase</code> should be a usable test on its own, so making it a mixin won't work. I only want to prevent it from getting executed extra times.</p>
  
  <p>Here is the desired outcome:</p>
  
  <ol>
  <li><p>Running just the <code>BaseTestCase</code> test in <code>test_doubled.py</code>:</p>
  
  <pre><code>$ python -m unittest discover -p test_doubled.py -v
  test_something (test_doubled.BaseTestCase) ... ok
  
  ----------------------------------------------------------------------
  Ran 1 test in 0.000s
  
  OK
  </code></pre>
  
  <p>This already works as desired.</p></li>
  <li><p>Running just the <code>DerivedTestCase</code> in <code>test_doubled_2.py</code>:</p>
  
  <pre><code>$ python -m unittest discover -p test_doubled_2.py -v
  test_something (test_doubled_2.DerivedTestCase) ... ok
  
  ----------------------------------------------------------------------
  Ran 2 tests in 0.000s
  
  OK
  </code></pre>
  
  <p>It should only execute the <code>DerivedTestCase</code>, and <em>not</em> the <code>BaseTestCase</code>.</p></li>
  <li><p>Running both:</p>
  
  <pre><code>$ python -m unittest discover -p test_doubled\*.py -v
  test_something (test_doubled.BaseTestCase) ... ok
  test_something (test_doubled_2.DerivedTestCase) ... ok
  
  ----------------------------------------------------------------------
  Ran 3 tests in 0.000s
  
  OK
  </code></pre>
  
  <p>The test method is executed exactly twice, once for <code>BaseTestcase</code> and once for <code>DerivedTestCase</code>.</p></li>
  </ol>