forked from cs360f16/Python-CI-Testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_list.py
More file actions
59 lines (42 loc) · 1.24 KB
/
test_list.py
File metadata and controls
59 lines (42 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python3
################################
# File Name: test_list.py
# Author: Chadd Williams
# Date: 11/7/2014
# Class: CS 360
# Assignment: Lecture Examples
# Purpose: build some tests that will be run by nosetests
################################
from nose import with_setup
from nose.tools import assert_equals
def test_simpleAddition():
assert 1+2 == 3
def setUp():
global theList
theList = []
def tearDown():
pass
@with_setup(setUp, tearDown)
def test_listAppend():
""" test that list append works
Since this function's name begins with 'test' and the
file name also begins with 'test', nosetests will
automatically discover and run this test when
nosetests is run
"""
theList.append(5)
assert theList[0] == 5
def dictSetup():
global mapping
mapping = { str(x):x for x in range(99) }
def dictTeardown():
pass
@with_setup(dictSetup, dictTeardown)
def test_dictSortedIterator():
value = 0
# the keys are strings, so they are sorted lexigraphically (1, 10, ...)
# use the key parameter to convert the key to an integer and sort
# numerically
for x in sorted(mapping.keys() , key=lambda data: int(data)) :
assert_equals( value , mapping[x])
value += 1