tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is
much faster, stable PEP8 compliant code style checker offering also
automatic formatting. It aims to be very stable and produce smallest
diffs. It's used by many small and big projects.
Running checkstyle with black takes a few seconds with a terse output.
Thus, test-checkstyle-diff is no longer necessary.
Expand scope of checkstyle to all python files in the repo, replacing
test-checkstyle with checkstyle-python.
Also, fixstyle-python is now available for automatic style formatting.
Note: python virtualenv has been consolidated in test/Makefile,
test/requirements*.txt which will eventually be moved to a central
location. This is required to simply the automated generation of
docker executor images in the CI.
Type: improvement
Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8
Signed-off-by: Klement Sekera <klement.sekera@gmail.com>
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
diff --git a/test/vpp_bier.py b/test/vpp_bier.py
index 6e087a8..9fdaf1f 100644
--- a/test/vpp_bier.py
+++ b/test/vpp_bier.py
@@ -18,7 +18,7 @@
BIER_HDR_PROTO_OAM = 8
-class VppBierTableID():
+class VppBierTableID:
def __init__(self, sub_domain_id, set_id, hdr_len_id):
self.set_id = set_id
self.sub_domain_id = sub_domain_id
@@ -28,9 +28,11 @@
def find_bier_table(test, bti):
tables = test.vapi.bier_table_dump()
for t in tables:
- if bti.set_id == t.bt_tbl_id.bt_set \
- and bti.sub_domain_id == t.bt_tbl_id.bt_sub_domain \
- and bti.hdr_len_id == t.bt_tbl_id.bt_hdr_len_id:
+ if (
+ bti.set_id == t.bt_tbl_id.bt_set
+ and bti.sub_domain_id == t.bt_tbl_id.bt_sub_domain
+ and bti.hdr_len_id == t.bt_tbl_id.bt_hdr_len_id
+ ):
return True
return False
@@ -38,10 +40,12 @@
def find_bier_route(test, bti, bp):
routes = test.vapi.bier_route_dump(bti)
for r in routes:
- if bti.set_id == r.br_route.br_tbl_id.bt_set \
- and bti.sub_domain_id == r.br_route.br_tbl_id.bt_sub_domain \
- and bti.hdr_len_id == r.br_route.br_tbl_id.bt_hdr_len_id \
- and bp == r.br_route.br_bp:
+ if (
+ bti.set_id == r.br_route.br_tbl_id.bt_set
+ and bti.sub_domain_id == r.br_route.br_tbl_id.bt_sub_domain
+ and bti.hdr_len_id == r.br_route.br_tbl_id.bt_hdr_len_id
+ and bp == r.br_route.br_bp
+ ):
return True
return False
@@ -57,8 +61,7 @@
def find_bier_disp_entry(test, bdti, bp):
entries = test.vapi.bier_disp_entry_dump(bdti)
for e in entries:
- if bp == e.bde_bp \
- and bdti == e.bde_tbl_id:
+ if bp == e.bde_bp and bdti == e.bde_tbl_id:
return True
return False
@@ -66,10 +69,12 @@
def find_bier_imp(test, bti, bp):
imps = test.vapi.bier_imp_dump()
for i in imps:
- if bti.set_id == i.bi_tbl_id.bt_set \
- and bti.sub_domain_id == i.bi_tbl_id.bt_sub_domain \
- and bti.hdr_len_id == i.bi_tbl_id.bt_hdr_len_id \
- and bp == i.bi_src:
+ if (
+ bti.set_id == i.bi_tbl_id.bt_set
+ and bti.sub_domain_id == i.bi_tbl_id.bt_sub_domain
+ and bti.hdr_len_id == i.bi_tbl_id.bt_hdr_len_id
+ and bp == i.bi_src
+ ):
return True
return False
@@ -85,22 +90,18 @@
self.mpls_label = mpls_label
def add_vpp_config(self):
- self._test.vapi.bier_table_add_del(
- self.id,
- self.mpls_label,
- is_add=1)
+ self._test.vapi.bier_table_add_del(self.id, self.mpls_label, is_add=1)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- self._test.vapi.bier_table_add_del(
- self.id,
- self.mpls_label,
- is_add=0)
+ self._test.vapi.bier_table_add_del(self.id, self.mpls_label, is_add=0)
def object_id(self):
- return "bier-table;[%d:%d:%d]" % (self.id.set_id,
- self.id.sub_domain_id,
- self.id.hdr_len_id)
+ return "bier-table;[%d:%d:%d]" % (
+ self.id.set_id,
+ self.id.sub_domain_id,
+ self.id.hdr_len_id,
+ )
def query_vpp_config(self):
return find_bier_table(self._test, self.id)
@@ -122,18 +123,14 @@
def add_vpp_config(self):
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- self.encoded_paths,
- is_add=1)
+ self.tbl_id, self.bp, self.encoded_paths, is_add=1
+ )
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- self.encoded_paths,
- is_add=0)
+ self.tbl_id, self.bp, self.encoded_paths, is_add=0
+ )
def update_paths(self, paths):
self.paths = paths
@@ -141,46 +138,37 @@
for path in self.paths:
self.encoded_paths.append(path.encode())
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- self.encoded_paths,
- is_replace=1)
+ self.tbl_id, self.bp, self.encoded_paths, is_replace=1
+ )
def add_path(self, path):
self.encoded_paths.append(path.encode())
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- [path.encode()],
- is_add=1,
- is_replace=0)
+ self.tbl_id, self.bp, [path.encode()], is_add=1, is_replace=0
+ )
self.paths.append(path)
self._test.registry.register(self, self._test.logger)
def remove_path(self, path):
self.encoded_paths.remove(path.encode())
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- [path.encode()],
- is_add=0,
- is_replace=0)
+ self.tbl_id, self.bp, [path.encode()], is_add=0, is_replace=0
+ )
self.paths.remove(path)
def remove_all_paths(self):
self._test.vapi.bier_route_add_del(
- self.tbl_id,
- self.bp,
- [],
- is_add=0,
- is_replace=1)
+ self.tbl_id, self.bp, [], is_add=0, is_replace=1
+ )
self.paths = []
def object_id(self):
- return "bier-route;[%d:%d:%d:%d]" % (self.tbl_id.set_id,
- self.tbl_id.sub_domain_id,
- self.tbl_id.hdr_len_id,
- self.bp)
+ return "bier-route;[%d:%d:%d:%d]" % (
+ self.tbl_id.set_id,
+ self.tbl_id.sub_domain_id,
+ self.tbl_id.hdr_len_id,
+ self.bp,
+ )
def query_vpp_config(self):
return find_bier_route(self._test, self.tbl_id, self.bp)
@@ -198,22 +186,20 @@
self.src = src
def add_vpp_config(self):
- res = self._test.vapi.bier_imp_add(
- self.tbl_id,
- self.src,
- self.ibytes)
+ res = self._test.vapi.bier_imp_add(self.tbl_id, self.src, self.ibytes)
self.bi_index = res.bi_index
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- self._test.vapi.bier_imp_del(
- self.bi_index)
+ self._test.vapi.bier_imp_del(self.bi_index)
def object_id(self):
- return "bier-imp;[%d:%d:%d:%d]" % (self.tbl_id.set_id,
- self.tbl_id.sub_domain_id,
- self.tbl_id.hdr_len_id,
- self.src)
+ return "bier-imp;[%d:%d:%d:%d]" % (
+ self.tbl_id.set_id,
+ self.tbl_id.sub_domain_id,
+ self.tbl_id.hdr_len_id,
+ self.src,
+ )
def query_vpp_config(self):
return find_bier_imp(self._test, self.tbl_id, self.src)
@@ -229,15 +215,11 @@
self.id = id
def add_vpp_config(self):
- self._test.vapi.bier_disp_table_add_del(
- self.id,
- is_add=1)
+ self._test.vapi.bier_disp_table_add_del(self.id, is_add=1)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- self._test.vapi.bier_disp_table_add_del(
- self.id,
- is_add=0)
+ self._test.vapi.bier_disp_table_add_del(self.id, is_add=0)
def object_id(self):
return "bier-disp-table;[%d]" % (self.id)
@@ -251,8 +233,9 @@
BIER Disposition Entry
"""
- def __init__(self, test, tbl_id, bp, payload_proto, nh_proto,
- nh, nh_tbl, rpf_id=~0):
+ def __init__(
+ self, test, tbl_id, bp, payload_proto, nh_proto, nh, nh_tbl, rpf_id=~0
+ ):
self._test = test
self.tbl_id = tbl_id
self.nh_tbl = nh_tbl
@@ -271,7 +254,8 @@
self.nh,
self.nh_tbl,
self.rpf_id,
- is_add=1)
+ is_add=1,
+ )
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
@@ -283,11 +267,11 @@
self.nh,
self.nh_tbl,
self.rpf_id,
- is_add=0)
+ is_add=0,
+ )
def object_id(self):
- return "bier-disp-entry;[%d:%d]" % (self.tbl_id,
- self.bp)
+ return "bier-disp-entry;[%d:%d]" % (self.tbl_id, self.bp)
def query_vpp_config(self):
return find_bier_disp_entry(self._test, self.tbl_id, self.bp)