Skip to content

Commit

Permalink
tests: remove remaining unittest invocation code
Browse files Browse the repository at this point in the history
We use nosetests instead.

Close #128.

Change-Id: Ib0158f2849e4e36063f59779a606a30f63554405
  • Loading branch information
thiell committed Apr 24, 2016
1 parent 7947a96 commit 4de5418
Show file tree
Hide file tree
Showing 22 changed files with 25 additions and 115 deletions.
2 changes: 1 addition & 1 deletion tests/CLIConfigTest.py
Expand Up @@ -150,7 +150,7 @@ def testClushConfigFull(self):
self.assertEqual(config.ssh_path, "/usr/bin/ssh")
self.assertEqual(config.ssh_options, "-oStrictHostKeyChecking=no")
f.close()

def testClushConfigError(self):
"""test CLI.Config.ClushConfig (error)"""

Expand Down
1 change: 0 additions & 1 deletion tests/CLIDisplayTest.py
Expand Up @@ -22,7 +22,6 @@
from ClusterShell.NodeUtils import GroupResolverConfig



def makeTestFile(text):
"""Create a temporary file with the provided text."""
f = tempfile.NamedTemporaryFile()
Expand Down
7 changes: 1 addition & 6 deletions tests/CLIOptionParserTest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# ClusterShell.CLI.OptionParser test suite
# Written by S. Thiell 2010-09-25
# Written by S. Thiell


"""Unit test for CLI.OptionParser"""
Expand Down Expand Up @@ -51,8 +51,3 @@ def testOptionParserClubak(self):
parser.install_nodes_options()
parser.install_display_options(separator_option=True, dshbak_compat=True)
options, _ = parser.parse_args([])


if __name__ == '__main__':
suites = [unittest.TestLoader().loadTestsFromTestCase(CLIOptionParserTest)]
unittest.TextTestRunner(verbosity=2).run(unittest.TestSuite(suites))
8 changes: 1 addition & 7 deletions tests/MisusageTest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# ClusterShell test suite
# Written by S. Thiell 2010-02-19
# Written by S. Thiell


"""Unit test for ClusterShell common library misusages"""
Expand Down Expand Up @@ -51,9 +51,3 @@ def testTaskScheduleTwice(self):
worker = task.shell("/bin/echo itsme")
self.assertRaises(WorkerError, task.schedule, worker)
task.abort()


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(MisusageTest)
unittest.TextTestRunner(verbosity=2).run(suite)

3 changes: 1 addition & 2 deletions tests/MsgTreeTest.py
Expand Up @@ -85,7 +85,7 @@ def test_003_iterators(self):
cnt += 1
self.assertEqual(cnt, 5)
self.assertEqual(len(list(iter(tree.items()))), 5)

# test walk() iterator (iterate by msg and give the list of
# associated keys)
cnt = 0
Expand Down Expand Up @@ -288,4 +288,3 @@ def test_010_remove_in_defer_mode(self):
[(['item1'], 'message0\nmessage3\nmessage5'),
(['item3'], 'message2'),
(['item2'], 'message6')])

10 changes: 1 addition & 9 deletions tests/RangeSetErrorTest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# ClusterShell.NodeSet.RangeSet error handling test suite
# Written by S. Thiell 2008-09-28
# Written by S. Thiell


"""Unit test for RangeSet errors"""
Expand All @@ -27,7 +27,6 @@ def _testRS(self, r, exc):
except:
raise
self.assert_(0, "error not detected/no exception raised")


def testBadUsages(self):
"""test parse errors"""
Expand All @@ -45,10 +44,3 @@ def testBadUsages(self):
self._testRS("4-2/-2", RangeSetParseError)
self._testRS("004-002", RangeSetParseError)
self._testRS("3-59/2,102a", RangeSetParseError)




if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(RangeSetErrorTest)
unittest.TextTestRunner(verbosity=2).run(suite)
14 changes: 4 additions & 10 deletions tests/RangeSetTest.py
Expand Up @@ -253,14 +253,14 @@ def testSubStep(self):
r1.difference_update(r2)
self.assertEqual(str(r1), "16-34/2")
self.assertEqual(len(r1), 10)

# case 3 diff right
r1 = RangeSet("4-34/2", autostep=3)
r2 = RangeSet("28-52/2", autostep=3)
r1.difference_update(r2)
self.assertEqual(str(r1), "4-26/2")
self.assertEqual(len(r1), 12)

# case 4 diff with ranges split
r1 = RangeSet("4-34/2", autostep=3)
r2 = RangeSet("12-18/2", autostep=3)
Expand Down Expand Up @@ -662,7 +662,7 @@ def testClear(self):
r1.clear()
self.assertEqual(len(r1), 0)
self.assertEqual(str(r1), "")

def testConstructorIterate(self):
"""test RangeSet(iterable) constructor"""
# from list
Expand Down Expand Up @@ -1037,7 +1037,7 @@ def testFolding(self):
self.assertEqual(str(r1), "112,114-117,119,121,130,132,134,136,138-141,144,147-148")
r1.autostep = 5
self.assertEqual(str(r1), "112,114-117,119,121,130-138/2,139-141,144,147-148")

r1 = RangeSet("1,3-4,6,8")
self.assertEqual(str(r1), "1,3-4,6,8")
r1 = RangeSet("1,3-4,6,8", autostep=4)
Expand Down Expand Up @@ -1094,9 +1094,3 @@ def test_dim(self):
self.assertEqual(r0.dim(), 0)
r1 = RangeSet("1-10,15-20")
self.assertEqual(r1.dim(), 1)


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(RangeSetTest)
unittest.TextTestRunner(verbosity=2).run(suite)

1 change: 0 additions & 1 deletion tests/TaskDistantPdshTest.py
Expand Up @@ -65,4 +65,3 @@ def setUp(self):
def tearDown(self):
DEFAULTS.engine = self.engine_id_save
task_terminate()

1 change: 0 additions & 1 deletion tests/TaskDistantTest.py
Expand Up @@ -65,4 +65,3 @@ def setUp(self):
def tearDown(self):
DEFAULTS.engine = self.engine_id_save
task_terminate()

5 changes: 2 additions & 3 deletions tests/TaskEventTest.py
Expand Up @@ -6,7 +6,9 @@
"""Unit test for ClusterShell Task (event-based mode)"""

import copy
import socket
import sys
import thread
import unittest

sys.path.insert(0, '../lib')
Expand All @@ -17,9 +19,6 @@
from ClusterShell.Task import *
from ClusterShell.Event import EventHandler

import socket
import thread


class TestHandler(EventHandler):

Expand Down
1 change: 0 additions & 1 deletion tests/TaskMsgTreeTest.py
Expand Up @@ -144,4 +144,3 @@ def testTaskModifyCommonStreams(self):
# only stderr should have been buffered at task level
self.assertEqual(len(list(task.iter_buffers())), 0)
self.assertEqual(len(list(task.iter_errors())), 1)

12 changes: 3 additions & 9 deletions tests/TaskPortTest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# ClusterShell test suite
# Written by S. Thiell 2009-12-19
# Written by S. Thiell


"""Unit test for ClusterShell inter-Task msg"""
Expand All @@ -23,7 +23,7 @@ def tearDown(self):

def testPortMsg1(self):
"""test port msg from main thread to task"""

TaskPortTest.got_msg = False

# create task in new thread
Expand All @@ -47,7 +47,7 @@ def ev_msg(self, port, msg):

def testPortRemove(self):
"""test port remove [private as of 1.2]"""

task = Task()

class PortHandler(EventHandler):
Expand All @@ -58,9 +58,3 @@ def ev_msg(self, port, msg):
task.resume()
task._remove_port(port)
task_wait()


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TaskPortTest)
unittest.TextTestRunner(verbosity=2).run(suite)

7 changes: 1 addition & 6 deletions tests/TaskRLimitsTest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# ClusterShell task resource consumption/limits test suite
# Written by S. Thiell 2010-10-19
# Written by S. Thiell


"""Unit test for ClusterShell Task (resource limits)"""
Expand Down Expand Up @@ -86,8 +86,3 @@ def testRemotePdsh(self):
def testRemotePdshStderr(self):
"""test resource usage with WorkerPdsh(stderr=True)"""
self._testRemotePdsh(True)

if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TaskRLimitsTest)
unittest.TextTestRunner(verbosity=2).run(suite)

1 change: 0 additions & 1 deletion tests/TaskThreadJoinTest.py
Expand Up @@ -121,4 +121,3 @@ def ev_read(self, worker):
time.sleep(1) # for pretty display, because unhandled exception
# traceback may be sent to stderr after the join()
self.assertFalse(task.running())

8 changes: 1 addition & 7 deletions tests/TaskThreadSuspendTest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# ClusterShell test suite
# Written by S. Thiell 2010-01-16
# Written by S. Thiell


"""Unit test for ClusterShell in multithreaded environments"""
Expand Down Expand Up @@ -75,9 +75,3 @@ def testThreadTaskWaitWithSuspend(self):
time.sleep(1)
task_wait()
self.assert_(self.resumed or suspended == False)


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TaskThreadSuspendTest)
unittest.TextTestRunner(verbosity=2).run(suite)

18 changes: 4 additions & 14 deletions tests/TaskTimeoutTest.py
@@ -1,12 +1,14 @@
#!/usr/bin/env python
# ClusterShell (local) test suite
# Written by S. Thiell 2009-02-09
# Written by S. Thiell


"""Unit test for ClusterShell Task/Worker timeout support"""

import copy
import socket
import sys
import thread
import unittest

sys.path.insert(0, '../lib')
Expand All @@ -16,13 +18,9 @@
from ClusterShell.NodeSet import NodeSet
from ClusterShell.Task import *

import socket

import thread


class TaskTimeoutTest(unittest.TestCase):

def testWorkersTimeoutBuffers(self):
"""test worker buffers with timeout"""
task = task_self()
Expand All @@ -40,11 +38,3 @@ def testWorkersTimeoutBuffers(self):
self.assertEqual(buf, """some buffer
here...""")
self.assertEqual(test, 0, "task.iter_buffers() did not work")




if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TaskTimeoutTest)
unittest.TextTestRunner(verbosity=2).run(suite)

6 changes: 3 additions & 3 deletions tests/TaskTimerTest.py
Expand Up @@ -86,7 +86,7 @@ def testSimpleTimerImmediate2(self):
class TRepeaterTimerChecker(EventHandler):
def __init__(self):
self.count = 0

def ev_timer(self, timer):
self.count += 1
timer.set_nextfire(0.2)
Expand Down Expand Up @@ -281,7 +281,7 @@ def testTimerSetNextFireInHandler(self):
task.resume()
# test timer did fire one time
self.assertEqual(test_eh.timer_count, 5)

class TEventHandlerTimerOtherInvalidate(EventHandler):
"""timer operations event handler simulator"""
def __init__(self, test):
Expand Down Expand Up @@ -415,7 +415,7 @@ def testAutocloseTimer(self):
# run task
task.resume()
self.assertEqual(test_handler.count, 0)

def testAutocloseWithTwoTimers(self):
"""test timer autoclose (two timers)"""
task = task_self()
Expand Down
1 change: 0 additions & 1 deletion tests/TreeCopyTest.py
Expand Up @@ -82,4 +82,3 @@ def test_rcopy(self):
task_self().rcopy(self.tfile.name, self.tdir, "n60")
task_self().resume()
self.assertTrue(self.test_ok)

1 change: 0 additions & 1 deletion tests/TreeTopologyTest.py
Expand Up @@ -440,4 +440,3 @@ def testStrConversions(self):
g = TopologyGraph()
# XXX: Actually if g is not empty other things will be printed out...
self.assertEquals(str(g), '<TopologyGraph>\n')

11 changes: 1 addition & 10 deletions tests/tree/CommunicationTest.py
Expand Up @@ -264,7 +264,7 @@ def testLocalChannel(self):

fin = open(ftest.name)
fout = open('/dev/null', 'w')

chan = _TestingChannel()
worker = WorkerSimple(fin, fout, None, None, handler=chan)

Expand Down Expand Up @@ -307,12 +307,3 @@ def testPrintableRepresentations(self):
"""test printing messages"""
msg = gen_cfg()
self.assertEquals(str(msg), 'Message CFG (msgid: 0, type: CFG)')

def main():
suite = unittest.TestLoader().loadTestsFromTestCase(CommunicationTest)
unittest.TextTestRunner(verbosity=2).run(suite)

if __name__ == '__main__':
#cProfile.run('main()')
main()

10 changes: 1 addition & 9 deletions tests/tree/GatewayTest.py
Expand Up @@ -42,7 +42,7 @@ def ev_close(self, worker):

class GatewayTest(unittest.TestCase):
"""TestCase for ClusterShell.Gateway module."""

def testCompletePropagation(self):
"""test a complete command propagation trip"""
#
Expand Down Expand Up @@ -107,11 +107,3 @@ def testCompletePropagation(self):
self.assertEquals(str(res), str(dst))
print "Complete propagation time: %fs for %d nodes" % \
(max(times) - min(times), len(dst))

def main():
suite = unittest.TestLoader().loadTestsFromTestCase(GatewayTest)
unittest.TextTestRunner(verbosity=2).run(suite)

if __name__ == '__main__':
main()

12 changes: 0 additions & 12 deletions tests/tree/PropagationTest.py
Expand Up @@ -26,8 +26,6 @@
from TLib import load_cfg, my_node




class PropagationTest(unittest.TestCase):
def setUp(self):
"""generate a sample topology tree"""
Expand Down Expand Up @@ -223,13 +221,3 @@ def testExecuteTasksOnNeighbors(self):
print '-' * 15
print buf
print ''


def main():
suite = unittest.TestLoader().loadTestsFromTestCase(PropagationTest)
unittest.TextTestRunner(verbosity=2).run(suite)

if __name__ == '__main__':
#cProfile.run('main()')
main()

0 comments on commit 4de5418

Please sign in to comment.