testing/nose: Restructure to split out examples
[swc-testing-nose.git] / testing / nose / exercises / mean / embedded-tests / mean.py
1 def mean(numlist):
2     try:
3         total = sum(numlist)
4         length = len(numlist)
5     except TypeError:
6         raise TypeError("The number list was not a list of numbers.")
7     except:
8         print "There was a problem evaluating the number list."
9     return total/length
10
11
12 def test_mean():
13     assert mean([0, 0, 0, 0]) == 0
14     assert mean([0, 200]) == 100
15     assert mean([0, -200]) == -100
16     assert mean([0]) == 0
17
18
19 def test_floating_mean():
20     assert mean([1, 2]) == 1.5