1
from subprocess import CalledProcessError
2
13
from subprocess import CalledProcessError
3
from helpers import command, unit_info
6
class testCommand(unittest.TestCase):
16
class TestCommand(unittest.TestCase):
8
18
def testSimpleCommand(self):
9
19
# Creating a simple command (ls) works and running the command
42
52
ls = command('/bin/ls')
46
class testUnit_info(unittest.TestCase):
55
def testOneLongArgument(self):
56
ls = command('/bin/ls')
57
with self.assertRaises(CalledProcessError):
58
ls('tests.py install')
60
def testSplitStringWorks(self):
61
ls = command('/bin/ls')
62
ls(*'tests.py install'.split())
65
class TestDictDiffer(unittest.TestCase):
68
a = dict(cow='moo', pig='oink')
69
b = dict(cow='moo', pig='oinkoink', horse='nay')
70
diff = DictDiffer(b, a)
72
self.assertIn("added: {'horse': None} -> {'horse': 'nay'}", s)
73
self.assertIn("removed: {} -> {}", s)
74
self.assertIn("changed: {'pig': 'oink'} -> {'pig': 'oinkoink'}", s)
75
self.assertIn("unchanged: ['cow']", s)
77
def testStrUnmodified(self):
78
a = dict(cow='moo', pig='oink')
79
diff = DictDiffer(a, a)
81
self.assertEquals('no changes', s)
83
def testAddedOrChanged(self):
84
a = dict(cow='moo', pig='oink')
85
b = dict(cow='moo', pig='oinkoink', horse='nay')
86
diff = DictDiffer(b, a)
87
expected = set(['horse', 'pig'])
88
self.assertEquals(expected, diff.added_or_changed)
91
class TestPicklers(unittest.TestCase):
93
def testSaveAndLoad(self):
94
fd = tempfile.NamedTemporaryFile()
99
retrieved = load_pickle(fn)
100
self.assertEquals(orig, retrieved)
103
class TestUnit_info(unittest.TestCase):
48
105
def make_data(self, state='started'):