From e1e81e315e41fd4674b9e10c2bd4074734d3692b Mon Sep 17 00:00:00 2001 From: Aly Sivji Date: Sat, 4 Aug 2018 08:29:55 -0500 Subject: [PATCH] code review 1/n -- change hasattr to getattr --- src/_pytest/assertion/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 4536cd0dd..b6867436e 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -123,10 +123,10 @@ def assertrepr_compare(config, op, left, right): return isinstance(x, (set, frozenset)) def isdatacls(obj): - return hasattr(obj, "__dataclass_fields__") + return getattr(obj, "__dataclass_fields__", None) is not None def isattrs(obj): - return hasattr(obj, "__attrs_attrs__") + return getattr(obj, "__attrs_attrs__", None) is not None def isiterable(obj): try: