Hi Matt,
I've learned that the best way to understand something is to try and explain it, so I'll give it a shot.
I don't think a basic HowTo discussion is off topic but if people object we can take it off-list.
Indeed unittests are a cool aid but they're not magic.
Very much simplified, they work best piecemeal and up front.
Done that way they tend to increase productivity and are fun to do.
Retro-fitting unittests to existing code, on the other hand, is a different matter all together.
I'd advise against it unless you have to (and in that case get a copy of this book first:
http://my.safaribooksonline.com/0131177052?bookview=toc)
Pythoscope can help with some of it but most of the frustrating work is still yours.
Ok, after that extended caveat, let's take a look at your example and see if we can identify the right incantation.
First off, note that an example of such incantation is commented out right before the 'assert False' statement.
Currently, the standard suggestions by Pythoscope are useful but fairly trivial, use them as a starting point to build your own incantations.
Pythoscope is capable of generating more concrete tests if you feed it examples of how your function is called btw.
A first attempt might look like this:
---- pythoscope inspired test 1 ----
import unittest
import drop_items
class TestGetFcList(unittest.TestCase):
def test_get_fc_list(self):
expected = [ "BS_1250009_0", "BS_1370009_2","BS_2000009_0",
"BS_2010009_0", "BS_2010009_2", "BS_2060009_0", "BS_2080009_0"]
self.assertEqual(expected, drop_items.get_fc_list())
------
Not very exciting but then the function under test doesn't actually do much either. It's really not more than a glorified constant at this point.
That could be all there is to it if the concrete values in the list are what's important.
Chances are that the values are only incidental.
Maybe what's really important is that the function returns a list with 7 elements for instance.
In that case our test might look more like this (in python 2.7):
---- pythoscope inspired test 2 ----
import unittest
import drop_items
class TestGetFcList(unittest.TestCase):
def test_get_fc_list_returns_list(self):
self.assertIsInstance(drop_items.get_fc_list(), list)
def test_get_fc_list_returns_7_elements(self):
expected = 7
fcs = drop_items.get_fc_list()
self.assertEqual(expected, len(fcs))
------
For a simple function as this we could even decide to skip unittests and instead write tests for its callers.
A lot more can be said about the subject but there's plenty of books and articles out there already so I'll leave it at that.
cheers,
Pieter