From 609ebd950421e14153df6e05a51aab73d99144e2 Mon Sep 17 00:00:00 2001 From: Sahid Orentino Ferdjaoui Date: Mon, 7 Nov 2022 13:17:56 +0100 Subject: [PATCH] test: fix docstring validation function For some reason in Python even if using getattr with None and as default value a string for the type __doc__ will return None. >>> type(getattr(None, "__doc__", "")) The error reported was: ft1.1: neutron.tests.functional.db.test_migrations.TestModelsMigrationsMySQL.test_branchestesttools.testresult.real._StringException: Traceback (most recent call last): File "/home/zuul/src/opendev.org/openstack/neutron/neutron/tests/base.py", line 182, in func return f(self, *args, **kwargs) File "/home/zuul/src/opendev.org/openstack/neutron/neutron/tests/functional/db/test_migrations.py", line 302, in test_branches find_migration_exceptions() File "/home/zuul/src/opendev.org/openstack/neutron/neutron/tests/functional/db/test_migrations.py", line 253, in find_migration_exceptions if len(explanation) < 1: TypeError: object of type 'NoneType' has no len() Signed-off-by: Sahid Orentino Ferdjaoui Change-Id: I7c03bac9c6e8dd074325f511e555c10fec8e77fc --- neutron/tests/functional/db/test_migrations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index 34c4e1fea84..f930c3aa01d 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -250,7 +250,7 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync): if not get_excepted_elements: continue explanation = getattr(get_excepted_elements, '__doc__', "") - if len(explanation) < 1: + if not explanation: self.fail("%s() requires docstring with explanation" % '.'.join([m.module.__name__, get_excepted_elements.__name__]))