On Tue, Dec 8, 2009 at 10:11 PM, Serdar Tumgoren <zstumgo...@gmail.com> wrote: > Hi Kent and Lie, > > First, thanks to you both for the help. I reworked the tests and then > the main code according to your suggestions (I really was muddling > these TDD concepts!). > > The reworked code and tests are below. In the tests, I hard-coded the > source data and the expected results; in the main program code, I > eliminated the FileCleaner class and converted its methods to > stand-alone functions. I'm planning to group them into a single, > larger "process" function as you all suggested. > > Meantime, I'd be grateful if you could critique whether I've properly > followed your advice.
Yes, this is much better. Notice how much less code it is! :-) > And of course, feel free to suggest other tests > that might be appropriate. For instance, would it make sense to test > convertEmDashes for non-unicode input? If you expect unicode input then it makes sense to test for it. If you don't expect unicode input, it might make sense to test for an expected error - how do you want the function to behave with invalid inputs? You could add other tests as well, for example does it work if there are two dashes in a row? Does splitLines() correctly remove blank lines? These are simple functions but the idea is to think of all the desired behaviours and write test cases to cover them. By the way I applaud your effort, unit testing is a valuable skill. Kent _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor