From bc90a7958104b1f2823c82c5a832eeb222d0d7e5 Mon Sep 17 00:00:00 2001 From: Brian O'Connor <bocon13@gmail.com> Date: Tue, 10 Sep 2013 15:56:27 -0700 Subject: [PATCH] cleaned up and commented test_multipoll.py --- examples/test/test_multipoll.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/test/test_multipoll.py b/examples/test/test_multipoll.py index 5c13f345..12321ea9 100755 --- a/examples/test/test_multipoll.py +++ b/examples/test/test_multipoll.py @@ -1,22 +1,21 @@ #!/usr/bin/env python -"""TEST""" +""" +Test for multipoll.py +""" import unittest import pexpect -from collections import defaultdict -from mininet.log import setLogLevel class testMultiPoll( unittest.TestCase ): - "Test ping with single switch topology (common code)." def testMultiPoll( self ): + "Verify that we receive one ping per second per host" p = pexpect.spawn( 'python -m mininet.examples.multipoll' ) - opts = [] - opts.append( "\*\*\* (h\d) :" ) - opts.append( "(h\d+): \d+ bytes from" ) - opts.append( "Monitoring output for (\d+) seconds" ) - opts.append( pexpect.EOF ) + opts = [ "\*\*\* (h\d) :" , + "(h\d+): \d+ bytes from", + "Monitoring output for (\d+) seconds", + pexpect.EOF ] pings = {} while True: index = p.expect( opts ) @@ -30,11 +29,10 @@ def testMultiPoll( self ): seconds = int( p.match.group( 1 ) ) else: break - self.assertTrue( len(pings) > 0 ) + self.assertTrue( len( pings ) > 0 ) # make sure we have received at least one ping per second for count in pings.values(): self.assertTrue( count >= seconds ) if __name__ == '__main__': - setLogLevel( 'warning' ) unittest.main() -- GitLab