From f6d62e2f691541fb5a1b6ff0564a5cf450d60c56 Mon Sep 17 00:00:00 2001 From: Henddher Pedroza Date: Sun, 28 Oct 2018 20:52:19 -0500 Subject: [PATCH] Harden mocked _obj_search() calls with passed in when applicable --- evennia/prototypes/tests.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/evennia/prototypes/tests.py b/evennia/prototypes/tests.py index ef09223cb1..38d577a408 100644 --- a/evennia/prototypes/tests.py +++ b/evennia/prototypes/tests.py @@ -394,23 +394,29 @@ class TestProtFuncs(EvenniaTest): with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: self.assertEqual(protlib.protfunc_parser("$objlist(#1)", session=self.session), ['#1']) mocked__obj_search.assert_called_once() + assert ('#1',) == mocked__obj_search.call_args[0] with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: self.assertEqual(protlib.protfunc_parser("$obj(#1)", session=self.session), '#1') mocked__obj_search.assert_called_once() + assert ('#1',) == mocked__obj_search.call_args[0] with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: self.assertEqual(protlib.protfunc_parser("$dbref(#1)", session=self.session), '#1') mocked__obj_search.assert_called_once() + assert ('#1',) == mocked__obj_search.call_args[0] with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: self.assertEqual(protlib.protfunc_parser("$obj(Char)", session=self.session), '#6') mocked__obj_search.assert_called_once() + assert ('Char',) == mocked__obj_search.call_args[0] # bad invocation - self.assertEqual(protlib.protfunc_parser("$badfunc(#1)", session=self.session), '') + with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: + self.assertEqual(protlib.protfunc_parser("$badfunc(#1)", session=self.session), '') + mocked__obj_search.assert_not_called() with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: self.assertEqual(protlib.protfunc_parser("$dbref(Char)", session=self.session), '')