diff options
author | Russell Bryant <russell@ovn.org> | 2015-12-12 12:54:31 -0500 |
---|---|---|
committer | Russell Bryant <russell@ovn.org> | 2016-01-05 18:13:47 -0500 |
commit | 3c057118d16ae0c7dc02c1c87ee2c19b401e39ce (patch) | |
tree | 50bb6e781d674bf29f49d6ecad7803c18c2732c1 /tests/test-ovsdb.py | |
parent | bdca6c4b56b9951b95c02f1fc13cbc78b16eee28 (diff) | |
download | openvswitch-3c057118d16ae0c7dc02c1c87ee2c19b401e39ce.tar.gz |
python: Resolve pep8 comparison errors.
Resolve pep8 errors:
E711 comparison to None should be 'if cond is None:'
The reason comparing against None with "is None" is preferred over
"== None" is because a class can define its own equality operator and
produce bizarre unexpected behavior. Using "is None" has a very
explicit meaning that can not be overridden.
E721 do not compare types, use 'isinstance()'
This one is actually a mistake by the tool in most cases.
'from ovs.db import types' looks just like types from the Python stdlib.
In those cases, use the full ovs.db.types name. Fix one case where it
actually was types from the stdlib.
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests/test-ovsdb.py')
-rw-r--r-- | tests/test-ovsdb.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py index 6ddc6b4f3..f121a0c8b 100644 --- a/tests/test-ovsdb.py +++ b/tests/test-ovsdb.py @@ -23,7 +23,7 @@ from ovs.db import error import ovs.db.idl import ovs.db.schema from ovs.db import data -from ovs.db import types +import ovs.db.types import ovs.ovsuuid import ovs.poller import ovs.util @@ -37,8 +37,8 @@ def unbox_json(json): def do_default_atoms(): - for type_ in types.ATOMIC_TYPES: - if type_ == types.VoidType: + for type_ in ovs.db.types.ATOMIC_TYPES: + if type_ == ovs.db.types.VoidType: continue sys.stdout.write("%s: " % type_.to_string()) @@ -54,15 +54,16 @@ def do_default_atoms(): def do_default_data(): any_errors = False for n_min in 0, 1: - for key in types.ATOMIC_TYPES: - if key == types.VoidType: + for key in ovs.db.types.ATOMIC_TYPES: + if key == ovs.db.types.VoidType: continue - for value in types.ATOMIC_TYPES: - if value == types.VoidType: + for value in ovs.db.types.ATOMIC_TYPES: + if value == ovs.db.types.VoidType: valueBase = None else: - valueBase = types.BaseType(value) - type_ = types.Type(types.BaseType(key), valueBase, n_min, 1) + valueBase = ovs.db.types.BaseType(value) + type_ = ovs.db.types.Type(ovs.db.types.BaseType(key), + valueBase, n_min, 1) assert type_.is_valid() sys.stdout.write("key %s, value %s, n_min %d: " @@ -80,25 +81,25 @@ def do_default_data(): def do_parse_atomic_type(type_string): type_json = unbox_json(ovs.json.from_string(type_string)) - atomic_type = types.AtomicType.from_json(type_json) + atomic_type = ovs.db.types.AtomicType.from_json(type_json) print ovs.json.to_string(atomic_type.to_json(), sort_keys=True) def do_parse_base_type(type_string): type_json = unbox_json(ovs.json.from_string(type_string)) - base_type = types.BaseType.from_json(type_json) + base_type = ovs.db.types.BaseType.from_json(type_json) print ovs.json.to_string(base_type.to_json(), sort_keys=True) def do_parse_type(type_string): type_json = unbox_json(ovs.json.from_string(type_string)) - type_ = types.Type.from_json(type_json) + type_ = ovs.db.types.Type.from_json(type_json) print ovs.json.to_string(type_.to_json(), sort_keys=True) def do_parse_atoms(type_string, *atom_strings): type_json = unbox_json(ovs.json.from_string(type_string)) - base = types.BaseType.from_json(type_json) + base = ovs.db.types.BaseType.from_json(type_json) for atom_string in atom_strings: atom_json = unbox_json(ovs.json.from_string(atom_string)) try: @@ -110,7 +111,7 @@ def do_parse_atoms(type_string, *atom_strings): def do_parse_data(type_string, *data_strings): type_json = unbox_json(ovs.json.from_string(type_string)) - type_ = types.Type.from_json(type_json) + type_ = ovs.db.types.Type.from_json(type_json) for datum_string in data_strings: datum_json = unbox_json(ovs.json.from_string(datum_string)) datum = data.Datum.from_json(type_, datum_json) @@ -119,7 +120,7 @@ def do_parse_data(type_string, *data_strings): def do_sort_atoms(type_string, atom_strings): type_json = unbox_json(ovs.json.from_string(type_string)) - base = types.BaseType.from_json(type_json) + base = ovs.db.types.BaseType.from_json(type_json) atoms = [data.Atom.from_json(base, atom_json) for atom_json in unbox_json(ovs.json.from_string(atom_strings))] print ovs.json.to_string([data.Atom.to_json(atom) |