From e8bc00eff22288c31a8ea36bf1faaa362d60d3cd Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Mon, 5 Mar 2012 14:03:46 -0800 Subject: [PATCH] Add assertRaises check to tools/hacking.py as N202 Change-Id: I25113bcc73ff642cae146f0558f319684b4568d0 --- tools/hacking.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/hacking.py b/tools/hacking.py index 19317ef8f630..75c795b9ca26 100755 --- a/tools/hacking.py +++ b/tools/hacking.py @@ -59,6 +59,16 @@ def nova_except_format(logical_line): return 6, "NOVA N201: no 'except:' at least use 'except Exception:'" +def nova_except_format(logical_line): + """ + nova HACKING guide recommends not using assertRaises(Exception...): + Do not use overly broad Exception type + N202 + """ + if logical_line.startswith("self.assertRaises(Exception"): + return 1, "NOVA N202: assertRaises Exception too broad" + + def nova_one_import_per_line(logical_line): """ nova HACKING guide recommends one import per line: