Name: [171] Florian Mayer
Member: 114 months
Authored: 7 videos
Description: I'm a student from Vienna, the federal capital of Austria. Please visit `My Blog <>`_ ...

Test Driven Development by Example [ID:851] (2/2)

in series: Unittesting with Python

video tutorial by Florian Mayer, added 08/08

(Showmedo is undergoing major changes. To report any problems viewing the videos please email us and include browser and OS specifics. Cheers - Kyran.)

This video is an introduction into test-driven development. It teaches you how to develop software using test-driven development at the example of a roman numeral converter.

class OutOfRangeError(Exception):

roman_numeral_map = (
    ('M', 1000), ('CM', 900),
    ('D',  500),  ('CD', 400),
    ('C',  100),  ('XC', 90),
    ('L',  50),    ('XL', 40),
    ('X',  10),   ('IX', 9),
    ('V',  5),     ('IV', 4), 
    ('I',  1))

def to_roman(x):
    output = ''
    if x < 1:
        raise OutOfRangeError
    for roman, normal in roman_numeral_map:
        while x - normal >= 0:
            output += roman
            x -= normal
    return output

import unittest
import roman_numerals

class ToRomanKnown(unittest.TestCase):
    def test_known(self):
        self.assertEqual(roman_numerals.to_roman(5), "V")
        self.assertEqual(roman_numerals.to_roman(10), "X")
        self.assertEqual(roman_numerals.to_roman(15), "XV")
        self.assertEqual(roman_numerals.to_roman(42), "XLII")
class ToRomanBadInput(unittest.TestCase):
    def test_zero(self):
        self.assertRaises(roman_numerals.OutOfRangeError, roman_numerals.to_roman, 0)
    def test_negative(self):
        self.assertRaises(roman_numerals.OutOfRangeError, roman_numerals.to_roman, -1)

if __name__ == '__main__':

Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 7 (since July 30th)
  • Plays in last week: 0
  • Published: 96 months ago

Thank-yous, questions and comments

If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?

You may also want to see our ShowMeDo Google Group to speak to our active users and authors.

Your email address will not be published.

Show some quick comments >>

All comments excluding tick-boxed quick-comments

22. JosephSon Sun, 26 Sep 2010 14:17

Nice intro

21. Wed, 01 Sep 2010 15:05

Very nice. I appreciate it.

I am glad I watched the video. I found this very helpful

19. jasa SEO, Backlink, Blogwalking murah Fri, 02 Apr 2010 16:03

Thanks. was good

18. the north face cheap jackets Thu, 18 Feb 2010 23:04

Quick, clear and to the point - well done.

17. true religion jumpers Tue, 16 Feb 2010 11:17

Thanks. For a beginner like me it was helpful to see how to actually run the tests (written tutorials seem to assume it to be obvious -_-;)

16. Dynatek Inc Thu, 11 Feb 2010 13:44

Great video, look forward to see more.

15. GeogLise Fri, 05 Feb 2010 15:06

Watched both part 1 and 2 or test driven development with python. I know test driven development but not python. Your videos were very good. Taught me how to get started using unittest. Thank you.

14. mbt asante review Sun, 24 Jan 2010 04:48

Great job! Really helpful introduction to TDD with easy to follow code.

13. anonymous Fri, 25 Dec 2009 12:40

great job! simple and clear.

12. anonymous Thu, 17 Dec 2009 06:42

very nice -- but perhaps a bit too fast, esp once you run the test. there's barely time to watch the results before you jump back. Remember that most likely the people watching this are learning about this, so they want to look at the output (fast coding is ok :-)

This is a minor problem however since we can just watch parts of the clip again I suppose. Thanks again for taking time to do this.

11. anonymous Wed, 09 Dec 2009 17:02

Good stuff ... thanks for clear examples

10. anonymous Mon, 30 Nov 2009 15:07

Good, succint video.

9. anonymous Mon, 16 Nov 2009 05:32

Really enjoyed your video. I'm actually a Java programmer. (I quite like Python though).

However, I was interested in the 'thought-processes' that a developer goes through when doing Test Driven Development.

8. anonymous Sat, 14 Nov 2009 06:44

Great job!!

I have been assigned unit testing using python..I have just started learning python, and ur videos are great to start with!!

7. anonymous Fri, 30 Oct 2009 23:43

Thank you again!

I am looking forward to the second installment.

6. anonymous Tue, 13 Oct 2009 20:23

Very helpful! Thank you.

5. anonymous Fri, 24 Jul 2009 07:35

thanks, was helpful.

4. anonymous Thu, 28 May 2009 21:52


3. anonymous Tue, 14 Apr 2009 20:28

nice work, man. i appreciate it

2. anonymous Tue, 14 Apr 2009 20:27

nice work, man. i appreciate it

The ShowMeDo Robot says - this video is now published, thanks for adding to ShowMeDo.

Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Florian

Decorators: Introducing functools.wraps


maccosmeticswholesalers mac makeup pencil c 17
72 months ago


Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.