buzzfeed / caliendo

caliendo
MIT License
16 stars 5 forks source link

@patch transform decorated non-test methods/functions into runnable tests #70

Open gerardo-orozco opened 10 years ago

gerardo-orozco commented 10 years ago

How to reproduce: given that we have one of the following scenarios

def foo():
    # do something

or

class MyTestCase(unittest.TestCase):
  def foo(self):
    # do something

if we run the tests, we should have 0 runing tests, but if we decorate foo() with @patch we'll have 1 test running (and probably failing, depending on the params it expects) because @patch(...) returns a function named patched_test which test runners assume is a runnable test

For some runners it also breaks the feature of running a single test like:

nosetests path.to.my.test_file
nosetests path.to.my.test_file:MyTestCase
nosetests path.to.my.test_file:MyTestCase.test_foo