Skip to content
Snippets Groups Projects
Commit 1471da95 authored by Bob Lantz's avatar Bob Lantz
Browse files

Fix pylint errors

parent 5a530af1
No related branches found
No related tags found
No related merge requests found
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
from distutils.version import StrictVersion from distutils.version import StrictVersion
def tsharkVersion(): def tsharkVersion():
"Return tshark version"
versionStr = quietRun( 'tshark -v' ) versionStr = quietRun( 'tshark -v' )
versionMatch = re.findall( 'TShark \d+.\d+.\d+', versionStr )[0] versionMatch = re.findall( r'TShark \d+.\d+.\d+', versionStr )[0]
return versionMatch.split()[ 1 ] return versionMatch.split()[ 1 ]
class testWalkthrough( unittest.TestCase ): class testWalkthrough( unittest.TestCase ):
"Test Mininet walkthrough"
prompt = 'mininet>' prompt = 'mininet>'
...@@ -31,6 +33,8 @@ def testHelp( self ): ...@@ -31,6 +33,8 @@ def testHelp( self ):
def testWireshark( self ): def testWireshark( self ):
"Use tshark to test the of dissector" "Use tshark to test the of dissector"
# Satisfy pylint:
assert self
if StrictVersion( tsharkVersion() ) < StrictVersion( '1.12.0' ): if StrictVersion( tsharkVersion() ) < StrictVersion( '1.12.0' ):
tshark = pexpect.spawn( 'tshark -i lo -R of' ) tshark = pexpect.spawn( 'tshark -i lo -R of' )
else: else:
...@@ -51,7 +55,7 @@ def testBasic( self ): ...@@ -51,7 +55,7 @@ def testBasic( self ):
self.assertEqual( index, 0, 'No output for "help" command') self.assertEqual( index, 0, 'No output for "help" command')
# nodes command # nodes command
p.sendline( 'nodes' ) p.sendline( 'nodes' )
p.expect( '([chs]\d ?){4}' ) p.expect( r'([chs]\d ?){4}' )
nodes = p.match.group( 0 ).split() nodes = p.match.group( 0 ).split()
self.assertEqual( len( nodes ), 4, 'No nodes in "nodes" command') self.assertEqual( len( nodes ), 4, 'No nodes in "nodes" command')
p.expect( self.prompt ) p.expect( self.prompt )
...@@ -67,7 +71,7 @@ def testBasic( self ): ...@@ -67,7 +71,7 @@ def testBasic( self ):
p.expect( self.prompt ) p.expect( self.prompt )
# dump command # dump command
p.sendline( 'dump' ) p.sendline( 'dump' )
expected = [ '<\w+ (%s)' % n for n in nodes ] expected = [ r'<\w+ (%s)' % n for n in nodes ]
actual = [] actual = []
for _ in nodes: for _ in nodes:
index = p.expect( expected ) index = p.expect( expected )
...@@ -161,7 +165,7 @@ def testRegressionRun( self ): ...@@ -161,7 +165,7 @@ def testRegressionRun( self ):
p.expect( pexpect.EOF ) p.expect( pexpect.EOF )
# test iperf # test iperf
p = pexpect.spawn( 'mn --test iperf' ) p = pexpect.spawn( 'mn --test iperf' )
p.expect( "Results: \['([\d\.]+) .bits/sec'," ) p.expect( r"Results: \['([\d\.]+) .bits/sec'," )
bw = float( p.match.group( 1 ) ) bw = float( p.match.group( 1 ) )
self.assertTrue( bw > 0 ) self.assertTrue( bw > 0 )
p.expect( pexpect.EOF ) p.expect( pexpect.EOF )
...@@ -170,7 +174,7 @@ def testTopoChange( self ): ...@@ -170,7 +174,7 @@ def testTopoChange( self ):
"Test pingall on single,3 and linear,4 topos" "Test pingall on single,3 and linear,4 topos"
# testing single,3 # testing single,3
p = pexpect.spawn( 'mn --test pingall --topo single,3' ) p = pexpect.spawn( 'mn --test pingall --topo single,3' )
p.expect( '(\d+)/(\d+) received') p.expect( r'(\d+)/(\d+) received')
received = int( p.match.group( 1 ) ) received = int( p.match.group( 1 ) )
sent = int( p.match.group( 2 ) ) sent = int( p.match.group( 2 ) )
self.assertEqual( sent, 6, 'Wrong number of pings sent in single,3' ) self.assertEqual( sent, 6, 'Wrong number of pings sent in single,3' )
...@@ -178,7 +182,7 @@ def testTopoChange( self ): ...@@ -178,7 +182,7 @@ def testTopoChange( self ):
p.expect( pexpect.EOF ) p.expect( pexpect.EOF )
# testing linear,4 # testing linear,4
p = pexpect.spawn( 'mn --test pingall --topo linear,4' ) p = pexpect.spawn( 'mn --test pingall --topo linear,4' )
p.expect( '(\d+)/(\d+) received') p.expect( r'(\d+)/(\d+) received')
received = int( p.match.group( 1 ) ) received = int( p.match.group( 1 ) )
sent = int( p.match.group( 2 ) ) sent = int( p.match.group( 2 ) )
self.assertEqual( sent, 12, 'Wrong number of pings sent in linear,4' ) self.assertEqual( sent, 12, 'Wrong number of pings sent in linear,4' )
...@@ -191,14 +195,14 @@ def testLinkChange( self ): ...@@ -191,14 +195,14 @@ def testLinkChange( self ):
# test bw # test bw
p.expect( self.prompt ) p.expect( self.prompt )
p.sendline( 'iperf' ) p.sendline( 'iperf' )
p.expect( "Results: \['([\d\.]+) Mbits/sec'," ) p.expect( r"Results: \['([\d\.]+) Mbits/sec'," )
bw = float( p.match.group( 1 ) ) bw = float( p.match.group( 1 ) )
self.assertTrue( bw < 10.1, 'Bandwidth > 10 Mb/s') self.assertTrue( bw < 10.1, 'Bandwidth > 10 Mb/s')
self.assertTrue( bw > 9.0, 'Bandwidth < 9 Mb/s') self.assertTrue( bw > 9.0, 'Bandwidth < 9 Mb/s')
p.expect( self.prompt ) p.expect( self.prompt )
# test delay # test delay
p.sendline( 'h1 ping -c 4 h2' ) p.sendline( 'h1 ping -c 4 h2' )
p.expect( 'rtt min/avg/max/mdev = ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' ) p.expect( r'rtt min/avg/max/mdev = ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' )
delay = float( p.match.group( 2 ) ) delay = float( p.match.group( 2 ) )
self.assertTrue( delay > 40, 'Delay < 40ms' ) self.assertTrue( delay > 40, 'Delay < 40ms' )
self.assertTrue( delay < 45, 'Delay > 40ms' ) self.assertTrue( delay < 45, 'Delay > 40ms' )
...@@ -243,7 +247,7 @@ def testSwitches( self ): ...@@ -243,7 +247,7 @@ def testSwitches( self ):
switches = [ 'user', 'ovsk' ] switches = [ 'user', 'ovsk' ]
for sw in switches: for sw in switches:
p = pexpect.spawn( 'mn --switch %s --test iperf' % sw ) p = pexpect.spawn( 'mn --switch %s --test iperf' % sw )
p.expect( "Results: \['([\d\.]+) .bits/sec'," ) p.expect( r"Results: \['([\d\.]+) .bits/sec'," )
bw = float( p.match.group( 1 ) ) bw = float( p.match.group( 1 ) )
self.assertTrue( bw > 0 ) self.assertTrue( bw > 0 )
p.expect( pexpect.EOF ) p.expect( pexpect.EOF )
...@@ -251,7 +255,7 @@ def testSwitches( self ): ...@@ -251,7 +255,7 @@ def testSwitches( self ):
def testBenchmark( self ): def testBenchmark( self ):
"Run benchmark and verify that it takes less than 2 seconds" "Run benchmark and verify that it takes less than 2 seconds"
p = pexpect.spawn( 'mn --test none' ) p = pexpect.spawn( 'mn --test none' )
p.expect( 'completed in ([\d\.]+) seconds' ) p.expect( r'completed in ([\d\.]+) seconds' )
time = float( p.match.group( 1 ) ) time = float( p.match.group( 1 ) )
self.assertTrue( time < 2, 'Benchmark takes more than 2 seconds' ) self.assertTrue( time < 2, 'Benchmark takes more than 2 seconds' )
...@@ -275,7 +279,7 @@ def testOwnNamespace( self ): ...@@ -275,7 +279,7 @@ def testOwnNamespace( self ):
self.assertEqual( ifcount, 2, 'Missing interfaces on s1' ) self.assertEqual( ifcount, 2, 'Missing interfaces on s1' )
# verify that all hosts a reachable # verify that all hosts a reachable
p.sendline( 'pingall' ) p.sendline( 'pingall' )
p.expect( '(\d+)% dropped' ) p.expect( r'(\d+)% dropped' )
dropped = int( p.match.group( 1 ) ) dropped = int( p.match.group( 1 ) )
self.assertEqual( dropped, 0, 'pingall failed') self.assertEqual( dropped, 0, 'pingall failed')
p.expect( self.prompt ) p.expect( self.prompt )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment