summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYoshihiro Kaneko <ykaneko0929@gmail.com>2014-05-14 12:47:19 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-05-14 13:20:58 +0900
commit857ec0c01999d0c16fe121b5bb5165b71b111db2 (patch)
treeac2c37393bedf274a7a408e90d6b5a5f1d1279d9
parentbd61cd5dd18d22bbdbfb67c34c13feae7a732204 (diff)
tests/unit: fix pep8
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/tests/unit/lib/test_rpc.py8
-rw-r--r--ryu/tests/unit/ofproto/test_parser_v10.py6
-rw-r--r--ryu/tests/unit/ofproto/test_parser_v12.py6
-rw-r--r--ryu/tests/unit/packet/test_bgp.py44
-rw-r--r--ryu/tests/unit/packet/test_icmpv6.py4
-rw-r--r--ryu/tests/unit/packet/test_ipv6.py6
-rw-r--r--ryu/tests/unit/packet/test_packet.py14
-rw-r--r--ryu/tests/unit/packet/test_sctp.py4
-rw-r--r--ryu/tests/unit/sample/test_sample1.py2
-rw-r--r--ryu/tests/unit/sample/test_sample2.py2
10 files changed, 42 insertions, 54 deletions
diff --git a/ryu/tests/unit/lib/test_rpc.py b/ryu/tests/unit/lib/test_rpc.py
index 735e049c..77b24393 100644
--- a/ryu/tests/unit/lib/test_rpc.py
+++ b/ryu/tests/unit/lib/test_rpc.py
@@ -249,7 +249,7 @@ class Test_rpc(unittest.TestCase):
c.receive_notification()
assert len(l) == 1
n = l.pop(0)
- assert not n is None
+ assert n is not None
method, params = n
assert method == "notify_hoge"
assert params[0] == obj
@@ -265,7 +265,7 @@ class Test_rpc(unittest.TestCase):
c.receive_notification()
assert len(l) == 1
n = l.pop(0)
- assert not n is None
+ assert n is not None
method, params = n
assert method == "notify_hoge"
assert params[0] == obj
@@ -355,14 +355,14 @@ class Test_rpc(unittest.TestCase):
assert done.issubset(s)
s -= done
r = e.get_request()
- if not r is None:
+ if r is not None:
msgid, method, params = r
assert method == "ourcallback"
omsgid, n, cb, v = params
assert omsgid in s
assert cb == "ourcallback"
assert n > 0
- e.send_response(msgid, result=[omsgid, n-1, cb, v+1])
+ e.send_response(msgid, result=[omsgid, n - 1, cb, v + 1])
assert sum == (1 + num_calls) * num_calls / 2
finally:
self._client_sock.setblocking(old_blocking)
diff --git a/ryu/tests/unit/ofproto/test_parser_v10.py b/ryu/tests/unit/ofproto/test_parser_v10.py
index 29f9f8a5..6a242846 100644
--- a/ryu/tests/unit/ofproto/test_parser_v10.py
+++ b/ryu/tests/unit/ofproto/test_parser_v10.py
@@ -1444,8 +1444,8 @@ class TestNXActionRegLoad(unittest.TestCase):
len_ = {'buf': '\x00\x18', 'val': ofproto.NX_ACTION_REG_MOVE_SIZE}
vendor = {'buf': '\x00\x00\x23\x20', 'val': ofproto.NX_VENDOR_ID}
subtype = {'buf': '\x00\x07', 'val': ofproto.NXAST_REG_LOAD}
- ofs_nbits = {'buf': '\x3d\x98', 'val': 15768}
- dst = {'buf': '\x9f\x9f\x88\x26', 'val': 2678032422}
+ ofs_nbits = {'buf': '\x3d\x98', 'val': 15768}
+ dst = {'buf': '\x9f\x9f\x88\x26', 'val': 2678032422}
value = {'buf': '\x33\x51\xcd\x43\x25\x28\x18\x99',
'val': 3697962457317775513}
@@ -2992,7 +2992,7 @@ class TestOFPVendor(unittest.TestCase):
eq_(data, res[5])
-#class TestNXTRequest(unittest.TestCase):
+# class TestNXTRequest(unittest.TestCase):
class TestNiciraHeader(unittest.TestCase):
""" Test case for ofproto_v1_0_parser.NiciraHeader
"""
diff --git a/ryu/tests/unit/ofproto/test_parser_v12.py b/ryu/tests/unit/ofproto/test_parser_v12.py
index 783d961b..1c288c8d 100644
--- a/ryu/tests/unit/ofproto/test_parser_v12.py
+++ b/ryu/tests/unit/ofproto/test_parser_v12.py
@@ -83,7 +83,7 @@ class TestMsgParser(unittest.TestCase):
msg_type = ofproto.OFPT_HELLO
fmt = ofproto.OFP_HEADER_PACK_STR
- buf = pack(fmt, version, msg_type, msg_len, xid)
+ buf = pack(fmt, version, msg_type, msg_len, xid)
c = msg_parser(_Datapath, version, msg_type, msg_len, xid, buf)
@@ -1454,7 +1454,7 @@ class TestOFPExperimenter(unittest.TestCase):
msg_len = ofproto.OFP_EXPERIMENTER_HEADER_SIZE
fmt = ofproto.OFP_HEADER_PACK_STR
- buf = pack(fmt, version, msg_type, msg_len, xid)
+ buf = pack(fmt, version, msg_type, msg_len, xid)
# OFP_EXPERIMENTER_HEADER_PACK_STR
# '!II'...experimenter, exp_type
@@ -6505,7 +6505,7 @@ class TestOFPRoleReply(unittest.TestCase):
# OFP_ROLE_REQUEST_PACK_STR
# '!I4xQ'...role, pad(4), generation_id
- #role = ofproto.OFPCR_ROLE_NOCHANGE
+ # role = ofproto.OFPCR_ROLE_NOCHANGE
role = 2147483648
generation_id = 1270985291017894273
diff --git a/ryu/tests/unit/packet/test_bgp.py b/ryu/tests/unit/packet/test_bgp.py
index 6764da4f..6ae8dca4 100644
--- a/ryu/tests/unit/packet/test_bgp.py
+++ b/ryu/tests/unit/packet/test_bgp.py
@@ -91,19 +91,13 @@ class Test_bgp(unittest.TestCase):
bgp.BGP_COMMUNITY_NO_ADVERTISE,
]
ecommunities = [
- bgp.BGPTwoOctetAsSpecificExtendedCommunity(subtype=1,
- as_number=65500,
- local_administrator=
- 3908876543),
- bgp.BGPFourOctetAsSpecificExtendedCommunity(subtype=2,
- as_number=10000000,
- local_administrator=
- 59876),
- bgp.BGPIPv4AddressSpecificExtendedCommunity(subtype=3,
- ipv4_address=
- '192.0.2.1',
- local_administrator=
- 65432),
+ bgp.BGPTwoOctetAsSpecificExtendedCommunity(
+ subtype=1, as_number=65500, local_administrator=3908876543),
+ bgp.BGPFourOctetAsSpecificExtendedCommunity(
+ subtype=2, as_number=10000000, local_administrator=59876),
+ bgp.BGPIPv4AddressSpecificExtendedCommunity(
+ subtype=3, ipv4_address='192.0.2.1',
+ local_administrator=65432),
bgp.BGPOpaqueExtendedCommunity(opaque='abcdefg'),
bgp.BGPUnknownExtendedCommunity(type_=99, value='abcdefg'),
]
@@ -128,7 +122,7 @@ class Test_bgp(unittest.TestCase):
nlri=mp_nlri),
bgp.BGPPathAttributeMpUnreachNLRI(afi=afi.IP, safi=safi.MPLS_VPN,
withdrawn_routes=mp_nlri),
- bgp.BGPPathAttributeUnknown(flags=0, type_=100, value=300*'bar')
+ bgp.BGPPathAttributeUnknown(flags=0, type_=100, value=300 * 'bar')
]
nlri = [
bgp.BGPNLRI(length=24, addr='203.0.113.1'),
@@ -240,19 +234,13 @@ class Test_bgp(unittest.TestCase):
bgp.BGP_COMMUNITY_NO_ADVERTISE,
]
ecommunities = [
- bgp.BGPTwoOctetAsSpecificExtendedCommunity(subtype=1,
- as_number=65500,
- local_administrator=
- 3908876543),
- bgp.BGPFourOctetAsSpecificExtendedCommunity(subtype=2,
- as_number=10000000,
- local_administrator=
- 59876),
- bgp.BGPIPv4AddressSpecificExtendedCommunity(subtype=3,
- ipv4_address=
- '192.0.2.1',
- local_administrator=
- 65432),
+ bgp.BGPTwoOctetAsSpecificExtendedCommunity(
+ subtype=1, as_number=65500, local_administrator=3908876543),
+ bgp.BGPFourOctetAsSpecificExtendedCommunity(
+ subtype=2, as_number=10000000, local_administrator=59876),
+ bgp.BGPIPv4AddressSpecificExtendedCommunity(
+ subtype=3, ipv4_address='192.0.2.1',
+ local_administrator=65432),
bgp.BGPOpaqueExtendedCommunity(opaque='abcdefg'),
bgp.BGPUnknownExtendedCommunity(type_=99, value='abcdefg'),
]
@@ -277,7 +265,7 @@ class Test_bgp(unittest.TestCase):
nlri=mp_nlri),
bgp.BGPPathAttributeMpUnreachNLRI(afi=afi.IP, safi=safi.MPLS_VPN,
withdrawn_routes=mp_nlri),
- bgp.BGPPathAttributeUnknown(flags=0, type_=100, value=300*'bar')
+ bgp.BGPPathAttributeUnknown(flags=0, type_=100, value=300 * 'bar')
]
nlri = [
bgp.BGPNLRI(length=24, addr='203.0.113.1'),
diff --git a/ryu/tests/unit/packet/test_icmpv6.py b/ryu/tests/unit/packet/test_icmpv6.py
index 6b5c3c27..745dacd0 100644
--- a/ryu/tests/unit/packet/test_icmpv6.py
+++ b/ryu/tests/unit/packet/test_icmpv6.py
@@ -1246,7 +1246,7 @@ class Test_mldv2_query(unittest.TestCase):
i = ipv6(nxt=inet.IPPROTO_ICMPV6)
ic = icmpv6.icmpv6(type_=icmpv6.MLD_LISTENER_QUERY,
data=self.mld)
- p = e/i/ic
+ p = e / i / ic
return p
def test_build_mldv2_query(self):
@@ -1520,7 +1520,7 @@ class Test_mldv2_report(unittest.TestCase):
i = ipv6(nxt=inet.IPPROTO_ICMPV6)
ic = icmpv6.icmpv6(type_=icmpv6.MLDV2_LISTENER_REPORT,
data=self.mld)
- p = e/i/ic
+ p = e / i / ic
return p
def test_build_mldv2_report(self):
diff --git a/ryu/tests/unit/packet/test_ipv6.py b/ryu/tests/unit/packet/test_ipv6.py
index 134a1c02..211df48d 100644
--- a/ryu/tests/unit/packet/test_ipv6.py
+++ b/ryu/tests/unit/packet/test_ipv6.py
@@ -760,7 +760,7 @@ class Test_routing(unittest.TestCase):
"2001:db8:dead::3"]
# calculate pad
self.pad = (8 - ((len(self.adrs) - 1) * (16 - self.cmpi) +
- (16 - self.cmpe) % 8)) % 8
+ (16 - self.cmpe) % 8)) % 8
# create buf
self.form = '!BBBBBB2x16s16s16s'
self.buf = struct.pack(self.form, self.nxt, self.size,
@@ -818,7 +818,7 @@ class Test_routing_type3(unittest.TestCase):
"2001:db8:dead::3"]
# calculate pad
self.pad = (8 - ((len(self.adrs) - 1) * (16 - self.cmpi) +
- (16 - self.cmpe) % 8)) % 8
+ (16 - self.cmpe) % 8)) % 8
self.routing = ipv6.routing_type3(
self.nxt, self.size, self.type_, self.seg, self.cmpi,
@@ -939,7 +939,7 @@ class Test_routing_type3(unittest.TestCase):
"2001:0db8:dead:0123:4567:89ab:cdef:0003"]
# calculate pad
pad = (8 - ((len(adrs) - 1) * (16 - cmpi) + (16 - cmpe) % 8)) % 8
- form = '!BBBBBB2x%ds%ds%ds' % (16-cmpi, 16-cmpi, 16-cmpe)
+ form = '!BBBBBB2x%ds%ds%ds' % (16 - cmpi, 16 - cmpi, 16 - cmpe)
slice_i = slice(cmpi, 16)
slice_e = slice(cmpe, 16)
buf = struct.pack(form, nxt, size, type_, seg,
diff --git a/ryu/tests/unit/packet/test_packet.py b/ryu/tests/unit/packet/test_packet.py
index b36a67eb..b4eacd6f 100644
--- a/ryu/tests/unit/packet/test_packet.py
+++ b/ryu/tests/unit/packet/test_packet.py
@@ -568,7 +568,7 @@ class TestPacket(unittest.TestCase):
ip = ipv4.ipv4(proto=inet.IPPROTO_SCTP)
s = sctp.sctp(chunks=[sctp.chunk_data(payload_data=self.payload)])
- p = e/ip/s
+ p = e / ip / s
p.serialize()
ipaddr = addrconv.ipv4.text_to_bin('0.0.0.0')
@@ -724,7 +724,7 @@ class TestPacket(unittest.TestCase):
ip = ipv4.ipv4(proto=inet.IPPROTO_ICMP)
ic = icmp.icmp()
- p = e/ip/ic
+ p = e / ip / ic
p.serialize()
ipaddr = addrconv.ipv4.text_to_bin('0.0.0.0')
@@ -858,7 +858,7 @@ class TestPacket(unittest.TestCase):
ip = ipv6.ipv6(nxt=inet.IPPROTO_UDP)
u = udp.udp()
- p = e/ip/u/self.payload
+ p = e / ip / u / self.payload
p.serialize()
ipaddr = addrconv.ipv6.text_to_bin('::')
@@ -979,7 +979,7 @@ class TestPacket(unittest.TestCase):
ip = ipv6.ipv6()
t = tcp.tcp(option='\x01\x02')
- p = e/ip/t/self.payload
+ p = e / ip / t / self.payload
p.serialize()
ipaddr = addrconv.ipv6.text_to_bin('::')
@@ -1117,7 +1117,7 @@ class TestPacket(unittest.TestCase):
ip = ipv6.ipv6(nxt=inet.IPPROTO_SCTP)
s = sctp.sctp(chunks=[sctp.chunk_data(payload_data=self.payload)])
- p = e/ip/s
+ p = e / ip / s
p.serialize()
ipaddr = addrconv.ipv6.text_to_bin('::')
@@ -1260,7 +1260,7 @@ class TestPacket(unittest.TestCase):
ip = ipv6.ipv6(nxt=inet.IPPROTO_ICMPV6)
ic = icmpv6.icmpv6()
- p = e/ip/ic
+ p = e / ip / ic
p.serialize()
ipaddr = addrconv.ipv6.text_to_bin('::')
@@ -1521,7 +1521,7 @@ class TestPacket(unittest.TestCase):
e = ethernet.ethernet(self.dst_mac, self.src_mac, ether.ETH_TYPE_IP)
i = ipv4.ipv4()
u = udp.udp(self.src_port, self.dst_port)
- pkt = e/i/u
+ pkt = e / i / u
ok_(isinstance(pkt, packet.Packet))
ok_(isinstance(pkt.protocols[0], ethernet.ethernet))
ok_(isinstance(pkt.protocols[1], ipv4.ipv4))
diff --git a/ryu/tests/unit/packet/test_sctp.py b/ryu/tests/unit/packet/test_sctp.py
index b4321a50..b5857f66 100644
--- a/ryu/tests/unit/packet/test_sctp.py
+++ b/ryu/tests/unit/packet/test_sctp.py
@@ -673,7 +673,7 @@ class Test_sctp(unittest.TestCase):
eq_(self.dst_port, res[1])
eq_(self.vtag, res[2])
# skip compare checksum
- #eq_(self.csum, res[3])
+ # eq_(self.csum, res[3])
return buf[sctp.sctp._MIN_LEN:]
@@ -1227,7 +1227,7 @@ class Test_sctp(unittest.TestCase):
ether.ETH_TYPE_IP)
ip4 = ipv4.ipv4(4, 5, 16, 0, 0, 2, 0, 64, inet.IPPROTO_SCTP, 0,
'192.168.1.1', '10.144.1.1')
- pkt = eth/ip4/self.sc
+ pkt = eth / ip4 / self.sc
eth = pkt.get_protocol(ethernet.ethernet)
ok_(eth)
diff --git a/ryu/tests/unit/sample/test_sample1.py b/ryu/tests/unit/sample/test_sample1.py
index e29dcf9a..34f8f69a 100644
--- a/ryu/tests/unit/sample/test_sample1.py
+++ b/ryu/tests/unit/sample/test_sample1.py
@@ -2,7 +2,7 @@
import unittest
from nose.tools import ok_, eq_
-#from ryu.app.simple_switch import SimpleSwitch
+# from ryu.app.simple_switch import SimpleSwitch
import logging
diff --git a/ryu/tests/unit/sample/test_sample2.py b/ryu/tests/unit/sample/test_sample2.py
index 74baca9b..9c21a42a 100644
--- a/ryu/tests/unit/sample/test_sample2.py
+++ b/ryu/tests/unit/sample/test_sample2.py
@@ -2,7 +2,7 @@
import unittest
from nose.tools import ok_, eq_
-#from ryu.app.simple_switch import SimpleSwitch
+# from ryu.app.simple_switch import SimpleSwitch
class TestSample2(unittest.TestCase):