From 9c7932d39f6b387141c33d36b86e9b39223ba3d4 Mon Sep 17 00:00:00 2001 From: Sergey Nikitin Date: Thu, 23 Oct 2014 16:32:33 +0400 Subject: [PATCH] Added hacking rule for assertEqual(a in b, True/False). The following replacements were done in tests to have clearer messages in case of failure: - assertEqual(a in b, True) with assertIn(a, b) - assertEqual(a in b, False) with assertNotIn(a, b) The error message would now be like: 'abc' not in ['a', 'b', 'c'] rather than: MismatchError: False != True Change-Id: I514daca3a470feef5d332a1a319cba15256fc6ea --- HACKING.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HACKING.rst b/HACKING.rst index d8850bab6..234acd4f0 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -49,6 +49,9 @@ Nova Specific Commandments - [N335] Check for usage of deprecated assertRaisesRegexp - [N336] Must use a dict comprehension instead of a dict constructor with a sequence of key-value pairs. - [N337] Don't import translation in tests +- [N338] Change assertEqual(A in B, True), assertEqual(True, A in B), + assertEqual(A in B, False) or assertEqual(False, A in B) to the more specific + assertIn/NotIn(A, B) Creating Unit Tests -------------------