2 Copyright (c) 2018-2019 Intel Corporation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
18 from unittest.mock import patch
24 __getattr__ = dict.get
27 class BaseExtractorsTestingClass(unittest.TestCase):
31 expected_call_args = None
34 if hasattr(self, 'patcher') and self.patcher: # pylint: disable=no-member
35 patcher = patch(self.patcher) # pylint: disable=no-member
36 self.addCleanup(patcher.stop)
37 self.infer_mock = patcher.start()
40 if hasattr(self, 'infer_mock'):
41 self.assertTrue(self.infer_mock.called)
42 for key, val in self.expected.items():
44 self.assertEqual(self.call_args, self.expected_call_args)
45 if type(val) is np.ndarray:
46 np.testing.assert_equal(val, self.res[key])
47 elif type(val) is list:
48 self.assertTrue(np.all([val == self.res[key]]))
50 self.assertEqual(val, self.res[key],
51 "{} attribute comparison failed! Expected {} but {} given.".format(key, val,
56 def __init__(self, param_key, param_val):
57 setattr(self, param_key, param_val)
61 def __init__(self, dict_values):
62 self.dict_values = dict_values
63 for (key, value) in dict_values.items():
64 # if type(value) != dict:
65 setattr(self, key, value)
67 # setattr(self, key, FakeMultiParam(value))
71 def __init__(self, param_key, param_val):
72 setattr(self, param_key, param_val)
76 def __init__(self, blobs_val):
77 self.blobs = [FakeBlob('data', val) for val in blobs_val]
81 def __init__(self, val):