Kyle Stanley <aeros...@gmail.com> added the comment:
> This might be a decent way to prevent the AttributeErrors, but still allows > for differentiation of actual None values Another alternative solution might be to use hasattr() before getattr(), if it is not desirable for test_pkg_import.py to raise exceptions: ``` self.assertTrue(hasattr(module, var), msg=f"{module} should have attribute {var}") self.assertEqual(getattr(module, var), 1) ``` That would follow more of a LBYL style, but I know that EAFP is more common within Python. The better alternative depends on the answer to my earlier question regarding exceptions being raised from the unit tests: > Is there a particular preference in the context of Python's tests? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37890> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com