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 def update_node(self):
26 __getattr__ = dict.get
29 class BaseExtractorsTestingClass(unittest.TestCase):
33 expected_call_args = None
36 if hasattr(self, 'patcher') and self.patcher: # pylint: disable=no-member
37 patcher = patch(self.patcher) # pylint: disable=no-member
38 self.addCleanup(patcher.stop)
39 self.infer_mock = patcher.start()
42 if hasattr(self, 'infer_mock'):
43 self.assertTrue(self.infer_mock.called)
44 for key, val in self.expected.items():
46 self.assertEqual(self.call_args, self.expected_call_args)
47 if type(val) is np.ndarray:
48 np.testing.assert_equal(val, self.res[key])
49 elif type(val) is list:
50 self.assertTrue(np.all([val == self.res[key]]))
52 self.assertAlmostEqual(val, self.res[key], 7,
53 "{} attribute comparison failed! Expected {} but {} given.".format(key, val,
58 def __init__(self, param_key, param_val):
59 setattr(self, param_key, param_val)
63 def __init__(self, dict_values):
64 self.dict_values = dict_values
65 for (key, value) in dict_values.items():
66 # if type(value) != dict:
67 setattr(self, key, value)
69 # setattr(self, key, FakeMultiParam(value))
73 def __init__(self, param_key, param_val):
74 setattr(self, param_key, param_val)
78 def __init__(self, blobs_val):
79 self.blobs = [FakeBlob('data', val) for val in blobs_val]
83 def __init__(self, val):