Skip to content

Commit 1471da9

Browse files
committed
Fix pylint errors
1 parent 5a530af commit 1471da9

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

mininet/test/test_walkthrough.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
from distutils.version import StrictVersion
1515

1616
def tsharkVersion():
17+
"Return tshark version"
1718
versionStr = quietRun( 'tshark -v' )
18-
versionMatch = re.findall( 'TShark \d+.\d+.\d+', versionStr )[0]
19+
versionMatch = re.findall( r'TShark \d+.\d+.\d+', versionStr )[0]
1920
return versionMatch.split()[ 1 ]
2021

2122
class testWalkthrough( unittest.TestCase ):
23+
"Test Mininet walkthrough"
2224

2325
prompt = 'mininet>'
2426

@@ -31,6 +33,8 @@ def testHelp( self ):
3133

3234
def testWireshark( self ):
3335
"Use tshark to test the of dissector"
36+
# Satisfy pylint:
37+
assert self
3438
if StrictVersion( tsharkVersion() ) < StrictVersion( '1.12.0' ):
3539
tshark = pexpect.spawn( 'tshark -i lo -R of' )
3640
else:
@@ -51,7 +55,7 @@ def testBasic( self ):
5155
self.assertEqual( index, 0, 'No output for "help" command')
5256
# nodes command
5357
p.sendline( 'nodes' )
54-
p.expect( '([chs]\d ?){4}' )
58+
p.expect( r'([chs]\d ?){4}' )
5559
nodes = p.match.group( 0 ).split()
5660
self.assertEqual( len( nodes ), 4, 'No nodes in "nodes" command')
5761
p.expect( self.prompt )
@@ -67,7 +71,7 @@ def testBasic( self ):
6771
p.expect( self.prompt )
6872
# dump command
6973
p.sendline( 'dump' )
70-
expected = [ '<\w+ (%s)' % n for n in nodes ]
74+
expected = [ r'<\w+ (%s)' % n for n in nodes ]
7175
actual = []
7276
for _ in nodes:
7377
index = p.expect( expected )
@@ -161,7 +165,7 @@ def testRegressionRun( self ):
161165
p.expect( pexpect.EOF )
162166
# test iperf
163167
p = pexpect.spawn( 'mn --test iperf' )
164-
p.expect( "Results: \['([\d\.]+) .bits/sec'," )
168+
p.expect( r"Results: \['([\d\.]+) .bits/sec'," )
165169
bw = float( p.match.group( 1 ) )
166170
self.assertTrue( bw > 0 )
167171
p.expect( pexpect.EOF )
@@ -170,15 +174,15 @@ def testTopoChange( self ):
170174
"Test pingall on single,3 and linear,4 topos"
171175
# testing single,3
172176
p = pexpect.spawn( 'mn --test pingall --topo single,3' )
173-
p.expect( '(\d+)/(\d+) received')
177+
p.expect( r'(\d+)/(\d+) received')
174178
received = int( p.match.group( 1 ) )
175179
sent = int( p.match.group( 2 ) )
176180
self.assertEqual( sent, 6, 'Wrong number of pings sent in single,3' )
177181
self.assertEqual( sent, received, 'Dropped packets in single,3')
178182
p.expect( pexpect.EOF )
179183
# testing linear,4
180184
p = pexpect.spawn( 'mn --test pingall --topo linear,4' )
181-
p.expect( '(\d+)/(\d+) received')
185+
p.expect( r'(\d+)/(\d+) received')
182186
received = int( p.match.group( 1 ) )
183187
sent = int( p.match.group( 2 ) )
184188
self.assertEqual( sent, 12, 'Wrong number of pings sent in linear,4' )
@@ -191,14 +195,14 @@ def testLinkChange( self ):
191195
# test bw
192196
p.expect( self.prompt )
193197
p.sendline( 'iperf' )
194-
p.expect( "Results: \['([\d\.]+) Mbits/sec'," )
198+
p.expect( r"Results: \['([\d\.]+) Mbits/sec'," )
195199
bw = float( p.match.group( 1 ) )
196200
self.assertTrue( bw < 10.1, 'Bandwidth > 10 Mb/s')
197201
self.assertTrue( bw > 9.0, 'Bandwidth < 9 Mb/s')
198202
p.expect( self.prompt )
199203
# test delay
200204
p.sendline( 'h1 ping -c 4 h2' )
201-
p.expect( 'rtt min/avg/max/mdev = ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' )
205+
p.expect( r'rtt min/avg/max/mdev = ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' )
202206
delay = float( p.match.group( 2 ) )
203207
self.assertTrue( delay > 40, 'Delay < 40ms' )
204208
self.assertTrue( delay < 45, 'Delay > 40ms' )
@@ -243,15 +247,15 @@ def testSwitches( self ):
243247
switches = [ 'user', 'ovsk' ]
244248
for sw in switches:
245249
p = pexpect.spawn( 'mn --switch %s --test iperf' % sw )
246-
p.expect( "Results: \['([\d\.]+) .bits/sec'," )
250+
p.expect( r"Results: \['([\d\.]+) .bits/sec'," )
247251
bw = float( p.match.group( 1 ) )
248252
self.assertTrue( bw > 0 )
249253
p.expect( pexpect.EOF )
250254

251255
def testBenchmark( self ):
252256
"Run benchmark and verify that it takes less than 2 seconds"
253257
p = pexpect.spawn( 'mn --test none' )
254-
p.expect( 'completed in ([\d\.]+) seconds' )
258+
p.expect( r'completed in ([\d\.]+) seconds' )
255259
time = float( p.match.group( 1 ) )
256260
self.assertTrue( time < 2, 'Benchmark takes more than 2 seconds' )
257261

@@ -275,7 +279,7 @@ def testOwnNamespace( self ):
275279
self.assertEqual( ifcount, 2, 'Missing interfaces on s1' )
276280
# verify that all hosts a reachable
277281
p.sendline( 'pingall' )
278-
p.expect( '(\d+)% dropped' )
282+
p.expect( r'(\d+)% dropped' )
279283
dropped = int( p.match.group( 1 ) )
280284
self.assertEqual( dropped, 0, 'pingall failed')
281285
p.expect( self.prompt )

0 commit comments

Comments
 (0)