title: How can I detect duplicate method names in a Python class?
body: <p>When writing unit tests, I sometimes cut and paste a test and don't remember to change the method name.  This results in overwriting the previous test, effectively hiding it and preventing it from running.  For example;</p>
  <pre><code>class WidgetTestCase(unittest.TestCase):
  
    def test_foo_should_do_some_behavior(self):
      self.assertEquals(42, self.widget.foo())
  
    def test_foo_should_do_some_behavior(self):
      self.widget.bar()
      self.assertEquals(314, self.widget.foo())
  </code></pre>
  <p>In this case, only the latter test would get called.  Is there a way of programmatically catching this sort of error, short of parsing the raw source code directly?</p>