-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_slices.py
executable file
·52 lines (39 loc) · 1.38 KB
/
test_slices.py
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
#! /usr/bin/python
# Copyright (c) 2015, Matthew P. Grosvenor
# All rights reserved. See LICENSE for more details
import sys
import redo
hosts = ["test%i" % x for x in range(0,15)]
redo = redo.Redo(hosts)
tests_index = [-1,1,"test7"]
results = ["['test14']", "['test1']", "['test7']"]
i = 1
for i in range(0,len(results)):
test = tests_index[i]
result = str(redo[test])
expect = results[i]
if not expect == result:
print "TEST %i: Failure: expected %s but got %s" % (i,result,expect)
else:
print "TEST %i: Success" % i
tests_slice = [ slice(-7,None, None), \
slice(3,sys.maxint,None), \
slice("test1","test7",None), \
slice("test1",None,None), \
slice(None,"test7",None) ]
def make_result(start,stop):
return "[" + ", ".join(["'test%i'" % i for i in range(start,stop)]) + "]"
results = [ make_result(8,15), \
make_result(3,15), \
make_result(1,8), \
make_result(1,15), \
make_result(0,8), \
]
for i in range(0,len(results)):
test = tests_slice[i]
result = str(redo[test])
expect = results[i]
if not expect == result:
print "TEST %i: Failure: expected %s but got %s" % (i + len(tests_index),result,expect)
else:
print "TEST %i: Success" % (i + len(tests_index))