Initializes test data.
(self, test_type)
| 153 | class MappableDataclassTest(parameterized.TestCase): |
| 154 | |
| 155 | def _init_testdata(self, test_type): |
| 156 | """Initializes test data.""" |
| 157 | map_cls, nested_map_cls = _get_mappable_dataclasses(test_type) |
| 158 | |
| 159 | self.dcls_with_map_inner = map_cls( |
| 160 | k_tuple=(1, 2), k_dict=dict(k1=32, k2=33)) |
| 161 | self.dcls_with_map_inner_inc = map_cls( |
| 162 | k_tuple=(2, 3), k_dict=dict(k1=33, k2=34)) |
| 163 | |
| 164 | self.dcls_no_map = ClassWithoutMap(k=dict(t='t', t2='t2')) |
| 165 | self.dcls_with_map = nested_map_cls( |
| 166 | k_any=None, |
| 167 | k_int=1, |
| 168 | k_str='test_str', |
| 169 | k_arr=np.array(16), |
| 170 | k_dclass_with_map=self.dcls_with_map_inner, |
| 171 | k_dclass_no_map=self.dcls_no_map) |
| 172 | |
| 173 | self.dcls_with_map_inc_ints = nested_map_cls( |
| 174 | k_any=None, |
| 175 | k_int=2, |
| 176 | k_str='test_str', |
| 177 | k_arr=np.array(16), |
| 178 | k_dclass_with_map=self.dcls_with_map_inner_inc, |
| 179 | k_dclass_no_map=self.dcls_no_map, |
| 180 | k_default='default_str') |
| 181 | |
| 182 | self.dcls_flattened_with_path = [ |
| 183 | (('k_any',), None), |
| 184 | (('k_arr',), np.array(16)), |
| 185 | (('k_dclass_no_map',), self.dcls_no_map), |
| 186 | (('k_dclass_with_map', 'k_dict', 'k1'), 32), |
| 187 | (('k_dclass_with_map', 'k_dict', 'k2'), 33), |
| 188 | (('k_dclass_with_map', 'k_tuple', 0), 1), |
| 189 | (('k_dclass_with_map', 'k_tuple', 1), 2), |
| 190 | (('k_default',), 'default_str'), |
| 191 | (('k_dict_factory', 'x'), 'x'), |
| 192 | (('k_dict_factory', 'y'), 'y'), |
| 193 | (('k_int',), 1), |
| 194 | (('k_non_init',), 10), |
| 195 | (('k_str',), 'test_str'), |
| 196 | ] |
| 197 | |
| 198 | self.dcls_flattened_with_path_up_to = [ |
| 199 | (('k_any',), None), |
| 200 | (('k_arr',), np.array(16)), |
| 201 | (('k_dclass_no_map',), self.dcls_no_map), |
| 202 | (('k_dclass_with_map',), self.dcls_with_map_inner), |
| 203 | (('k_default',), 'default_str'), |
| 204 | (('k_dict_factory', 'x'), 'x'), |
| 205 | (('k_dict_factory', 'y'), 'y'), |
| 206 | (('k_int',), 1), |
| 207 | (('k_non_init',), 10), |
| 208 | (('k_str',), 'test_str'), |
| 209 | ] |
| 210 | |
| 211 | self.dcls_flattened = [v for (_, v) in self.dcls_flattened_with_path] |
| 212 | self.dcls_flattened_up_to = [ |
no test coverage detected