@@ -244,8 +244,9 @@ class TestFetch(unittest.TestCase):
244244 self .assertEqual (sock .sent , [b'EHLO x\r \n ' ])
245245
246246 def test_dialog_reports_a_connection_closed_before_the_pattern (self ):
247- success , message = self ._fetch (FakeSocket ([b'220 ready\n ' ]),
248- dialog = [(None , '250' )])
247+ success , message = self ._fetch (
248+ FakeSocket ([b'220 ready\n ' ]), dialog = [(None , '250' )]
249+ )
249250 self .assertFalse (success )
250251 self .assertIn ('closed before pattern' , message )
251252
@@ -411,12 +412,14 @@ class TestGetNetinfo(unittest.TestCase):
411412 self .assertEqual (net .get_netinfo (), [])
412413
413414 def test_reports_the_address_of_the_default_route (self ):
414- with mock .patch .object (net , 'HAVE_PSUTIL' , True ), \
415- mock .patch .object (net , '_default_route_ip' , return_value = '192.0.2.10' ), \
416- mock .patch .object (
417- net , '_iface_for_ip' , return_value = ('eth0' , '255.255.255.0' )
418- ), \
419- mock .patch .object (net , '_default_gateway' , return_value = '192.0.2.1' ):
415+ with (
416+ mock .patch .object (net , 'HAVE_PSUTIL' , True ),
417+ mock .patch .object (net , '_default_route_ip' , return_value = '192.0.2.10' ),
418+ mock .patch .object (
419+ net , '_iface_for_ip' , return_value = ('eth0' , '255.255.255.0' )
420+ ),
421+ mock .patch .object (net , '_default_gateway' , return_value = '192.0.2.1' ),
422+ ):
420423 netinfo = net .get_netinfo ()
421424 self .assertEqual (netinfo ['address' ], '192.0.2.10' )
422425 self .assertEqual (netinfo ['mask' ], '255.255.255.0' )
@@ -426,8 +429,10 @@ class TestGetNetinfo(unittest.TestCase):
426429 self .assertIsNone (netinfo ['public_address' ])
427430
428431 def test_without_a_default_route_it_returns_an_empty_list (self ):
429- with mock .patch .object (net , 'HAVE_PSUTIL' , True ), \
430- mock .patch .object (net , '_default_route_ip' , return_value = None ):
432+ with (
433+ mock .patch .object (net , 'HAVE_PSUTIL' , True ),
434+ mock .patch .object (net , '_default_route_ip' , return_value = None ),
435+ ):
431436 self .assertEqual (net .get_netinfo (), [])
432437
433438
@@ -441,7 +446,9 @@ class TestGetSubnetHosts(unittest.TestCase):
441446 return have , module
442447
443448 def test_lists_the_hosts_of_the_interface_subnet (self ):
444- addr = mock .Mock (family = net .AF_INET , address = '192.0.2.1' , netmask = '255.255.255.0' )
449+ addr = mock .Mock (
450+ family = net .AF_INET , address = '192.0.2.1' , netmask = '255.255.255.0'
451+ )
445452 have , module = self ._interfaces ({'eth0' : [addr ]})
446453 with have , module :
447454 success , hosts = net .get_subnet_hosts ('eth0' )
@@ -451,21 +458,27 @@ class TestGetSubnetHosts(unittest.TestCase):
451458
452459 def test_without_an_interface_it_asks_get_netinfo (self ):
453460 netinfo = {'address' : '192.0.2.1' , 'mask_cidr' : 24 }
454- with mock .patch .object (net , 'HAVE_PSUTIL' , True ), \
455- mock .patch .object (net , 'get_netinfo' , return_value = netinfo ):
461+ with (
462+ mock .patch .object (net , 'HAVE_PSUTIL' , True ),
463+ mock .patch .object (net , 'get_netinfo' , return_value = netinfo ),
464+ ):
456465 success , hosts = net .get_subnet_hosts ()
457466 self .assertTrue (success , hosts )
458467 self .assertEqual (len (hosts ), 254 )
459468
460469 def test_without_a_default_route_it_says_so (self ):
461- with mock .patch .object (net , 'HAVE_PSUTIL' , True ), \
462- mock .patch .object (net , 'get_netinfo' , return_value = []):
470+ with (
471+ mock .patch .object (net , 'HAVE_PSUTIL' , True ),
472+ mock .patch .object (net , 'get_netinfo' , return_value = []),
473+ ):
463474 success , message = net .get_subnet_hosts ()
464475 self .assertFalse (success )
465476 self .assertIn ('default interface' , message )
466477
467478 def test_max_hosts_is_honoured (self ):
468- addr = mock .Mock (family = net .AF_INET , address = '192.0.2.1' , netmask = '255.255.255.0' )
479+ addr = mock .Mock (
480+ family = net .AF_INET , address = '192.0.2.1' , netmask = '255.255.255.0'
481+ )
469482 have , module = self ._interfaces ({'eth0' : [addr ]})
470483 with have , module :
471484 success , message = net .get_subnet_hosts ('eth0' , max_hosts = 10 )
@@ -485,5 +498,6 @@ class TestGetSubnetHosts(unittest.TestCase):
485498 self .assertFalse (success )
486499 self .assertIn ('psutil' , message )
487500
501+
488502if __name__ == '__main__' :
489503 unittest .main ()
0 commit comments