Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I indicate that a test hasn't been written yet in Python?

I'm doing TDD using Python and the unittest module. In NUnit you can Assert.Inconclusive("This test hasn't been written yet").

So far I haven't been able to find anything similar in Python to indicate that "These tests are just placeholders, I need to come back and actually put the code in them."

Is there a Pythonic pattern for this?

like image 350
Wayne Werner Avatar asked Aug 24 '12 13:08

Wayne Werner


3 Answers

With the new and updated unittest module you can skip tests:

@skip("skip this test")
def testSomething(self):
    pass # TODO

def testBar(self):
    self.skipTest('We need a test here, really')

def testFoo(self):
    raise SkipTest('TODO: Write a test here too')

When the test runner runs these, they are counted separately ("skipped: (n)").

like image 133
Martijn Pieters Avatar answered Sep 22 '22 19:09

Martijn Pieters


I would not let them pass or show OK, because you will not find them easily back.

Maybe just let them fail and the reason (not written yet), which seems logical because you have a test that is not finished.

like image 36
Michel Keijzers Avatar answered Sep 22 '22 19:09

Michel Keijzers


I often use self.fail as a todo list

def test_some_edge_case(self):
    self.fail('Need to check for wibbles')

Works well for me when I'm doing tdd.

like image 29
aychedee Avatar answered Sep 22 '22 19:09

aychedee