[style] update python style to conform to PEP 8 (#3951)

With the exception of line length set to 119 vs. 79.

Add tests/ and tools/ to py-pretty-check.
This commit is contained in:
Jonathan Hui
2019-07-11 11:45:55 -04:00
committed by GitHub
parent a938ee2845
commit f924adcb60
341 changed files with 8702 additions and 4460 deletions
+95 -55
View File
@@ -92,7 +92,6 @@ def any_tlvs_data(count=None):
class TestTargetEid(unittest.TestCase):
def test_should_return_eid_value_when_eid_property_is_called(self):
# GIVEN
eid = any_eid()
@@ -105,7 +104,8 @@ class TestTargetEid(unittest.TestCase):
# THEN
self.assertEqual(eid, actual_eid)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
eid = any_eid()
@@ -116,8 +116,8 @@ class TestTargetEid(unittest.TestCase):
class TestTargetEidFactory(unittest.TestCase):
def test_should_create_TargetEid_from_bytearray_when_parse_method_is_called(self):
def test_should_create_TargetEid_from_bytearray_when_parse_method_is_called(
self):
# GIVEN
eid = any_eid()
@@ -132,8 +132,8 @@ class TestTargetEidFactory(unittest.TestCase):
class TestMacExtendedAddress(unittest.TestCase):
def test_should_return_mac_address_value_when_mac_address_property_is_called(self):
def test_should_return_mac_address_value_when_mac_address_property_is_called(
self):
# GIVEN
mac_address = any_mac_extended_address()
@@ -145,34 +145,40 @@ class TestMacExtendedAddress(unittest.TestCase):
# THEN
self.assertEqual(mac_address, actual_mac_address)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
mac_address = any_mac_extended_address()
mac_extended_address = network_layer.MacExtendedAddress(mac_address)
# THEN
self.assertEqual(mac_extended_address, network_layer.MacExtendedAddress(mac_address))
self.assertEqual(
mac_extended_address, network_layer.MacExtendedAddress(mac_address)
)
class TestMacExtendedAddressFactory(unittest.TestCase):
def test_should_create_MacExtendedAddress_from_bytearray_when_parse_method_is_called(self):
def test_should_create_MacExtendedAddress_from_bytearray_when_parse_method_is_called(
self):
# GIVEN
mac_address = any_mac_extended_address()
factory = network_layer.MacExtendedAddressFactory()
# WHEN
mac_extended_address = factory.parse(io.BytesIO(mac_address), common.MessageInfo())
mac_extended_address = factory.parse(
io.BytesIO(mac_address), common.MessageInfo()
)
# THEN
self.assertTrue(isinstance(mac_extended_address, network_layer.MacExtendedAddress))
self.assertTrue(
isinstance(mac_extended_address, network_layer.MacExtendedAddress)
)
self.assertEqual(mac_address, mac_extended_address.mac_address)
class TestRloc16(unittest.TestCase):
def test_should_return_rloc16_value_when_rloc16_property_is_called(self):
# GIVEN
rloc16 = any_rloc16()
@@ -185,7 +191,8 @@ class TestRloc16(unittest.TestCase):
# THEN
self.assertEqual(rloc16, actual_rloc16)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
rloc16 = any_rloc16()
@@ -196,8 +203,9 @@ class TestRloc16(unittest.TestCase):
class TestRloc16Factory(unittest.TestCase):
def test_should_create_Rloc16_from_bytearray_when_parse_method_is_called(self):
def test_should_create_Rloc16_from_bytearray_when_parse_method_is_called(
self
):
# GIVEN
rloc16 = any_rloc16()
@@ -214,7 +222,6 @@ class TestRloc16Factory(unittest.TestCase):
class TestMlEid(unittest.TestCase):
def test_should_return_ml_eid_value_when_ml_eid_property_is_called(self):
# GIVEN
ml_eid = any_ml_eid()
@@ -227,7 +234,8 @@ class TestMlEid(unittest.TestCase):
# THEN
self.assertEqual(ml_eid, actual_ml_eid)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
ml_eid = any_ml_eid()
@@ -238,8 +246,9 @@ class TestMlEid(unittest.TestCase):
class TestMlEidFactory(unittest.TestCase):
def test_should_create_MlEid_from_bytearray_when_parse_method_is_called(self):
def test_should_create_MlEid_from_bytearray_when_parse_method_is_called(
self
):
# GIVEN
ml_eid = any_ml_eid()
@@ -254,7 +263,6 @@ class TestMlEidFactory(unittest.TestCase):
class TestStatus(unittest.TestCase):
def test_should_return_status_value_when_status_property_is_called(self):
# GIVEN
status = any_status()
@@ -267,7 +275,8 @@ class TestStatus(unittest.TestCase):
# THEN
self.assertEqual(status, actual_status)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
status = any_status()
@@ -278,8 +287,9 @@ class TestStatus(unittest.TestCase):
class TestStatusFactory(unittest.TestCase):
def test_should_create_Status_from_bytearray_when_parse_method_is_called(self):
def test_should_create_Status_from_bytearray_when_parse_method_is_called(
self
):
# GIVEN
status = any_status()
@@ -296,12 +306,13 @@ class TestStatusFactory(unittest.TestCase):
class TestTimeSinceLastTransaction(unittest.TestCase):
def test_should_return_seconds_value_when_seconds_property_is_called(self):
# GIVEN
seconds = any_seconds()
time_since_last_transaction = network_layer.TimeSinceLastTransaction(seconds)
time_since_last_transaction = network_layer.TimeSinceLastTransaction(
seconds
)
# WHEN
actual_seconds = time_since_last_transaction.seconds
@@ -309,19 +320,25 @@ class TestTimeSinceLastTransaction(unittest.TestCase):
# THEN
self.assertEqual(seconds, actual_seconds)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
seconds = any_seconds()
time_since_last_transaction = network_layer.TimeSinceLastTransaction(seconds)
time_since_last_transaction = network_layer.TimeSinceLastTransaction(
seconds
)
# THEN
self.assertEqual(time_since_last_transaction, network_layer.TimeSinceLastTransaction(seconds))
self.assertEqual(
time_since_last_transaction,
network_layer.TimeSinceLastTransaction(seconds),
)
class TestTimeSinceLastTransactionFactory(unittest.TestCase):
def test_should_create_TimeSinceLastTransaction_from_bytearray_when_parse_method_is_called(self):
def test_should_create_TimeSinceLastTransaction_from_bytearray_when_parse_method_is_called(
self):
# GIVEN
seconds = any_seconds()
@@ -330,20 +347,29 @@ class TestTimeSinceLastTransactionFactory(unittest.TestCase):
data = bytearray(struct.pack(">L", seconds))
# WHEN
time_since_last_transaction = factory.parse(io.BytesIO(data), common.MessageInfo())
time_since_last_transaction = factory.parse(
io.BytesIO(data), common.MessageInfo()
)
# THEN
self.assertTrue(isinstance(time_since_last_transaction, network_layer.TimeSinceLastTransaction))
self.assertTrue(
isinstance(
time_since_last_transaction,
network_layer.TimeSinceLastTransaction,
)
)
self.assertEqual(seconds, time_since_last_transaction.seconds)
class TestRouterMask(unittest.TestCase):
def test_should_return_id_sequence_value_when_id_sequence_property_is_called(self):
def test_should_return_id_sequence_value_when_id_sequence_property_is_called(
self):
# GIVEN
id_sequence = any_id_sequence()
router_mask = network_layer.RouterMask(id_sequence, any_router_id_mask())
router_mask = network_layer.RouterMask(
id_sequence, any_router_id_mask()
)
# WHEN
actual_id_sequence = router_mask.id_sequence
@@ -351,11 +377,14 @@ class TestRouterMask(unittest.TestCase):
# THEN
self.assertEqual(id_sequence, actual_id_sequence)
def test_should_return_router_id_mask_value_when_router_id_mask_property_is_called(self):
def test_should_return_router_id_mask_value_when_router_id_mask_property_is_called(
self):
# GIVEN
router_id_mask = any_router_id_mask()
router_mask = network_layer.RouterMask(any_id_sequence(), router_id_mask)
router_mask = network_layer.RouterMask(
any_id_sequence(), router_id_mask
)
# WHEN
actual_router_id_mask = router_mask.router_id_mask
@@ -363,7 +392,8 @@ class TestRouterMask(unittest.TestCase):
# THEN
self.assertEqual(router_id_mask, actual_router_id_mask)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
id_sequence = any_id_sequence()
router_id_mask = any_router_id_mask()
@@ -371,12 +401,14 @@ class TestRouterMask(unittest.TestCase):
router_mask = network_layer.RouterMask(id_sequence, router_id_mask)
# THEN
self.assertEqual(router_mask, network_layer.RouterMask(id_sequence, router_id_mask))
self.assertEqual(
router_mask, network_layer.RouterMask(id_sequence, router_id_mask)
)
class TestRouterMaskFactory(unittest.TestCase):
def test_should_create_RouterMask_from_bytearray_when_parse_method_is_called(self):
def test_should_create_RouterMask_from_bytearray_when_parse_method_is_called(
self):
# GIVEN
id_sequence = any_id_sequence()
router_id_mask = any_router_id_mask()
@@ -395,7 +427,6 @@ class TestRouterMaskFactory(unittest.TestCase):
class TestNdOption(unittest.TestCase):
def test_should_return_options_value_when_options_property_is_called(self):
# GIVEN
options = any_options()
@@ -408,7 +439,8 @@ class TestNdOption(unittest.TestCase):
# THEN
self.assertEqual(options, actual_options)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
options = any_options()
@@ -419,8 +451,9 @@ class TestNdOption(unittest.TestCase):
class TestNdOptionFactory(unittest.TestCase):
def test_should_create_NdOption_from_bytearray_when_parse_method_is_called(self):
def test_should_create_NdOption_from_bytearray_when_parse_method_is_called(
self
):
# GIVEN
options = any_options()
@@ -437,7 +470,6 @@ class TestNdOptionFactory(unittest.TestCase):
class TestThreadNetworkData(unittest.TestCase):
def test_should_return_options_value_when_options_property_is_called(self):
# GIVEN
tlvs = any_tlvs_data()
@@ -450,34 +482,42 @@ class TestThreadNetworkData(unittest.TestCase):
# THEN
self.assertEqual(tlvs, actual_tlvs)
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(
self):
# GIVEN
tlvs = any_tlvs_data()
thread_network_data = network_layer.ThreadNetworkData(tlvs)
# THEN
self.assertEqual(thread_network_data, network_layer.ThreadNetworkData(tlvs))
self.assertEqual(
thread_network_data, network_layer.ThreadNetworkData(tlvs)
)
class TestThreadNetworkDataFactory(unittest.TestCase):
def test_should_create_ThreadNetworkData_from_bytearray_when_parse_method_is_called(self):
def test_should_create_ThreadNetworkData_from_bytearray_when_parse_method_is_called(
self):
# GIVEN
tlvs = any_tlvs_data()
class DummyNetworkDataTlvsFactory:
def parse(self, data, message_info):
return bytearray(data.read())
factory = network_layer.ThreadNetworkDataFactory(DummyNetworkDataTlvsFactory())
factory = network_layer.ThreadNetworkDataFactory(
DummyNetworkDataTlvsFactory()
)
# WHEN
thread_network_data = factory.parse(io.BytesIO(tlvs), common.MessageInfo())
thread_network_data = factory.parse(
io.BytesIO(tlvs), common.MessageInfo()
)
# THEN
self.assertTrue(isinstance(thread_network_data, network_layer.ThreadNetworkData))
self.assertTrue(
isinstance(thread_network_data, network_layer.ThreadNetworkData)
)
self.assertEqual(tlvs, thread_network_data.tlvs)