Best JavaScript code snippet using wpt
test_nvlist.py
Source:test_nvlist.py
1#2# Copyright 2015 ClusterHQ3#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 at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# 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 and14# limitations under the License.15#16"""17Tests for _nvlist module.18The tests convert from a `dict` to C ``nvlist_t`` and back to a `dict`19and verify that no information is lost and value types are correct.20The tests also check that various error conditions like unsupported21value types or out of bounds values are detected.22"""23from __future__ import absolute_import, division, print_function24import unittest25from .._nvlist import nvlist_in, nvlist_out, _lib26from ..ctypes import (27 uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t,28 uint64_t, int64_t, boolean_t, uchar_t29)30class TestNVList(unittest.TestCase):31 def _dict_to_nvlist_to_dict(self, props):32 res = {}33 nv_in = nvlist_in(props)34 with nvlist_out(res) as nv_out:35 _lib.nvlist_dup(nv_in, nv_out, 0)36 return res37 def _assertIntDictsEqual(self, dict1, dict2):38 self.assertEqual(39 len(dict1), len(dict1),40 b"resulting dictionary is of different size")41 for key in dict1.keys():42 self.assertEqual(int(dict1[key]), int(dict2[key]))43 def _assertIntArrayDictsEqual(self, dict1, dict2):44 self.assertEqual(45 len(dict1), len(dict1),46 b"resulting dictionary is of different size")47 for key in dict1.keys():48 val1 = dict1[key]49 val2 = dict2[key]50 self.assertEqual(51 len(val1), len(val2), b"array values of different sizes")52 for x, y in zip(val1, val2):53 self.assertEqual(int(x), int(y))54 def test_empty(self):55 res = self._dict_to_nvlist_to_dict({})56 self.assertEqual(len(res), 0, b"expected empty dict")57 def test_invalid_key_type(self):58 with self.assertRaises(TypeError):59 self._dict_to_nvlist_to_dict({1: None})60 def test_invalid_val_type__tuple(self):61 with self.assertRaises(TypeError):62 self._dict_to_nvlist_to_dict({b"key": (1, 2)})63 def test_invalid_val_type__set(self):64 with self.assertRaises(TypeError):65 self._dict_to_nvlist_to_dict({b"key": set(1, 2)})66 def test_invalid_array_val_type(self):67 with self.assertRaises(TypeError):68 self._dict_to_nvlist_to_dict({b"key": [(1, 2), (3, 4)]})69 def test_invalid_array_of_arrays_val_type(self):70 with self.assertRaises(TypeError):71 self._dict_to_nvlist_to_dict({b"key": [[1, 2], [3, 4]]})72 def test_string_value(self):73 props = {b"key": b"value"}74 res = self._dict_to_nvlist_to_dict(props)75 self.assertEqual(props, res)76 def test_implicit_boolean_value(self):77 props = {b"key": None}78 res = self._dict_to_nvlist_to_dict(props)79 self.assertEqual(props, res)80 def test_boolean_values(self):81 props = {b"key1": True, b"key2": False}82 res = self._dict_to_nvlist_to_dict(props)83 self.assertEqual(props, res)84 def test_explicit_boolean_true_value(self):85 props = {b"key": boolean_t(1)}86 res = self._dict_to_nvlist_to_dict(props)87 self._assertIntDictsEqual(props, res)88 def test_explicit_boolean_false_value(self):89 props = {b"key": boolean_t(0)}90 res = self._dict_to_nvlist_to_dict(props)91 self._assertIntDictsEqual(props, res)92 def test_explicit_boolean_invalid_value(self):93 with self.assertRaises(OverflowError):94 props = {b"key": boolean_t(2)}95 self._dict_to_nvlist_to_dict(props)96 def test_explicit_boolean_another_invalid_value(self):97 with self.assertRaises(OverflowError):98 props = {b"key": boolean_t(-1)}99 self._dict_to_nvlist_to_dict(props)100 def test_uint64_value(self):101 props = {b"key": 1}102 res = self._dict_to_nvlist_to_dict(props)103 self.assertEqual(props, res)104 def test_uint64_max_value(self):105 props = {b"key": 2 ** 64 - 1}106 res = self._dict_to_nvlist_to_dict(props)107 self.assertEqual(props, res)108 def test_uint64_too_large_value(self):109 props = {b"key": 2 ** 64}110 with self.assertRaises(OverflowError):111 self._dict_to_nvlist_to_dict(props)112 def test_uint64_negative_value(self):113 props = {b"key": -1}114 with self.assertRaises(OverflowError):115 self._dict_to_nvlist_to_dict(props)116 def test_explicit_uint64_value(self):117 props = {b"key": uint64_t(1)}118 res = self._dict_to_nvlist_to_dict(props)119 self._assertIntDictsEqual(props, res)120 def test_explicit_uint64_max_value(self):121 props = {b"key": uint64_t(2 ** 64 - 1)}122 res = self._dict_to_nvlist_to_dict(props)123 self._assertIntDictsEqual(props, res)124 def test_explicit_uint64_too_large_value(self):125 with self.assertRaises(OverflowError):126 props = {b"key": uint64_t(2 ** 64)}127 self._dict_to_nvlist_to_dict(props)128 def test_explicit_uint64_negative_value(self):129 with self.assertRaises(OverflowError):130 props = {b"key": uint64_t(-1)}131 self._dict_to_nvlist_to_dict(props)132 def test_explicit_uint32_value(self):133 props = {b"key": uint32_t(1)}134 res = self._dict_to_nvlist_to_dict(props)135 self._assertIntDictsEqual(props, res)136 def test_explicit_uint32_max_value(self):137 props = {b"key": uint32_t(2 ** 32 - 1)}138 res = self._dict_to_nvlist_to_dict(props)139 self._assertIntDictsEqual(props, res)140 def test_explicit_uint32_too_large_value(self):141 with self.assertRaises(OverflowError):142 props = {b"key": uint32_t(2 ** 32)}143 self._dict_to_nvlist_to_dict(props)144 def test_explicit_uint32_negative_value(self):145 with self.assertRaises(OverflowError):146 props = {b"key": uint32_t(-1)}147 self._dict_to_nvlist_to_dict(props)148 def test_explicit_uint16_value(self):149 props = {b"key": uint16_t(1)}150 res = self._dict_to_nvlist_to_dict(props)151 self._assertIntDictsEqual(props, res)152 def test_explicit_uint16_max_value(self):153 props = {b"key": uint16_t(2 ** 16 - 1)}154 res = self._dict_to_nvlist_to_dict(props)155 self._assertIntDictsEqual(props, res)156 def test_explicit_uint16_too_large_value(self):157 with self.assertRaises(OverflowError):158 props = {b"key": uint16_t(2 ** 16)}159 self._dict_to_nvlist_to_dict(props)160 def test_explicit_uint16_negative_value(self):161 with self.assertRaises(OverflowError):162 props = {b"key": uint16_t(-1)}163 self._dict_to_nvlist_to_dict(props)164 def test_explicit_uint8_value(self):165 props = {b"key": uint8_t(1)}166 res = self._dict_to_nvlist_to_dict(props)167 self._assertIntDictsEqual(props, res)168 def test_explicit_uint8_max_value(self):169 props = {b"key": uint8_t(2 ** 8 - 1)}170 res = self._dict_to_nvlist_to_dict(props)171 self._assertIntDictsEqual(props, res)172 def test_explicit_uint8_too_large_value(self):173 with self.assertRaises(OverflowError):174 props = {b"key": uint8_t(2 ** 8)}175 self._dict_to_nvlist_to_dict(props)176 def test_explicit_uint8_negative_value(self):177 with self.assertRaises(OverflowError):178 props = {b"key": uint8_t(-1)}179 self._dict_to_nvlist_to_dict(props)180 def test_explicit_byte_value(self):181 props = {b"key": uchar_t(1)}182 res = self._dict_to_nvlist_to_dict(props)183 self._assertIntDictsEqual(props, res)184 def test_explicit_byte_max_value(self):185 props = {b"key": uchar_t(2 ** 8 - 1)}186 res = self._dict_to_nvlist_to_dict(props)187 self._assertIntDictsEqual(props, res)188 def test_explicit_byte_too_large_value(self):189 with self.assertRaises(OverflowError):190 props = {b"key": uchar_t(2 ** 8)}191 self._dict_to_nvlist_to_dict(props)192 def test_explicit_byte_negative_value(self):193 with self.assertRaises(OverflowError):194 props = {b"key": uchar_t(-1)}195 self._dict_to_nvlist_to_dict(props)196 def test_explicit_int64_value(self):197 props = {b"key": int64_t(1)}198 res = self._dict_to_nvlist_to_dict(props)199 self._assertIntDictsEqual(props, res)200 def test_explicit_int64_max_value(self):201 props = {b"key": int64_t(2 ** 63 - 1)}202 res = self._dict_to_nvlist_to_dict(props)203 self._assertIntDictsEqual(props, res)204 def test_explicit_int64_min_value(self):205 props = {b"key": int64_t(-(2 ** 63))}206 res = self._dict_to_nvlist_to_dict(props)207 self._assertIntDictsEqual(props, res)208 def test_explicit_int64_too_large_value(self):209 with self.assertRaises(OverflowError):210 props = {b"key": int64_t(2 ** 63)}211 self._dict_to_nvlist_to_dict(props)212 def test_explicit_int64_too_small_value(self):213 with self.assertRaises(OverflowError):214 props = {b"key": int64_t(-(2 ** 63) - 1)}215 self._dict_to_nvlist_to_dict(props)216 def test_explicit_int32_value(self):217 props = {b"key": int32_t(1)}218 res = self._dict_to_nvlist_to_dict(props)219 self._assertIntDictsEqual(props, res)220 def test_explicit_int32_max_value(self):221 props = {b"key": int32_t(2 ** 31 - 1)}222 res = self._dict_to_nvlist_to_dict(props)223 self._assertIntDictsEqual(props, res)224 def test_explicit_int32_min_value(self):225 props = {b"key": int32_t(-(2 ** 31))}226 res = self._dict_to_nvlist_to_dict(props)227 self._assertIntDictsEqual(props, res)228 def test_explicit_int32_too_large_value(self):229 with self.assertRaises(OverflowError):230 props = {b"key": int32_t(2 ** 31)}231 self._dict_to_nvlist_to_dict(props)232 def test_explicit_int32_too_small_value(self):233 with self.assertRaises(OverflowError):234 props = {b"key": int32_t(-(2 ** 31) - 1)}235 self._dict_to_nvlist_to_dict(props)236 def test_explicit_int16_value(self):237 props = {b"key": int16_t(1)}238 res = self._dict_to_nvlist_to_dict(props)239 self._assertIntDictsEqual(props, res)240 def test_explicit_int16_max_value(self):241 props = {b"key": int16_t(2 ** 15 - 1)}242 res = self._dict_to_nvlist_to_dict(props)243 self._assertIntDictsEqual(props, res)244 def test_explicit_int16_min_value(self):245 props = {b"key": int16_t(-(2 ** 15))}246 res = self._dict_to_nvlist_to_dict(props)247 self._assertIntDictsEqual(props, res)248 def test_explicit_int16_too_large_value(self):249 with self.assertRaises(OverflowError):250 props = {b"key": int16_t(2 ** 15)}251 self._dict_to_nvlist_to_dict(props)252 def test_explicit_int16_too_small_value(self):253 with self.assertRaises(OverflowError):254 props = {b"key": int16_t(-(2 ** 15) - 1)}255 self._dict_to_nvlist_to_dict(props)256 def test_explicit_int8_value(self):257 props = {b"key": int8_t(1)}258 res = self._dict_to_nvlist_to_dict(props)259 self._assertIntDictsEqual(props, res)260 def test_explicit_int8_max_value(self):261 props = {b"key": int8_t(2 ** 7 - 1)}262 res = self._dict_to_nvlist_to_dict(props)263 self._assertIntDictsEqual(props, res)264 def test_explicit_int8_min_value(self):265 props = {b"key": int8_t(-(2 ** 7))}266 res = self._dict_to_nvlist_to_dict(props)267 self._assertIntDictsEqual(props, res)268 def test_explicit_int8_too_large_value(self):269 with self.assertRaises(OverflowError):270 props = {b"key": int8_t(2 ** 7)}271 self._dict_to_nvlist_to_dict(props)272 def test_explicit_int8_too_small_value(self):273 with self.assertRaises(OverflowError):274 props = {b"key": int8_t(-(2 ** 7) - 1)}275 self._dict_to_nvlist_to_dict(props)276 def test_nested_dict(self):277 props = {b"key": {}}278 res = self._dict_to_nvlist_to_dict(props)279 self.assertEqual(props, res)280 def test_nested_nested_dict(self):281 props = {b"key": {b"key": {}}}282 res = self._dict_to_nvlist_to_dict(props)283 self.assertEqual(props, res)284 def test_mismatching_values_array(self):285 props = {b"key": [1, b"string"]}286 with self.assertRaises(TypeError):287 self._dict_to_nvlist_to_dict(props)288 def test_mismatching_values_array2(self):289 props = {b"key": [True, 10]}290 with self.assertRaises(TypeError):291 self._dict_to_nvlist_to_dict(props)292 def test_mismatching_values_array3(self):293 props = {b"key": [1, False]}294 with self.assertRaises(TypeError):295 self._dict_to_nvlist_to_dict(props)296 def test_string_array(self):297 props = {b"key": [b"value", b"value2"]}298 res = self._dict_to_nvlist_to_dict(props)299 self.assertEqual(props, res)300 def test_boolean_array(self):301 props = {b"key": [True, False]}302 res = self._dict_to_nvlist_to_dict(props)303 self.assertEqual(props, res)304 def test_explicit_boolean_array(self):305 props = {b"key": [boolean_t(False), boolean_t(True)]}306 res = self._dict_to_nvlist_to_dict(props)307 self._assertIntArrayDictsEqual(props, res)308 def test_uint64_array(self):309 props = {b"key": [0, 1, 2 ** 64 - 1]}310 res = self._dict_to_nvlist_to_dict(props)311 self.assertEqual(props, res)312 def test_uint64_array_too_large_value(self):313 props = {b"key": [0, 2 ** 64]}314 with self.assertRaises(OverflowError):315 self._dict_to_nvlist_to_dict(props)316 def test_uint64_array_negative_value(self):317 props = {b"key": [0, -1]}318 with self.assertRaises(OverflowError):319 self._dict_to_nvlist_to_dict(props)320 def test_mixed_explict_int_array(self):321 with self.assertRaises(TypeError):322 props = {b"key": [uint64_t(0), uint32_t(0)]}323 self._dict_to_nvlist_to_dict(props)324 def test_explict_uint64_array(self):325 props = {b"key": [uint64_t(0), uint64_t(1), uint64_t(2 ** 64 - 1)]}326 res = self._dict_to_nvlist_to_dict(props)327 self._assertIntArrayDictsEqual(props, res)328 def test_explict_uint64_array_too_large_value(self):329 with self.assertRaises(OverflowError):330 props = {b"key": [uint64_t(0), uint64_t(2 ** 64)]}331 self._dict_to_nvlist_to_dict(props)332 def test_explict_uint64_array_negative_value(self):333 with self.assertRaises(OverflowError):334 props = {b"key": [uint64_t(0), uint64_t(-1)]}335 self._dict_to_nvlist_to_dict(props)336 def test_explict_uint32_array(self):337 props = {b"key": [uint32_t(0), uint32_t(1), uint32_t(2 ** 32 - 1)]}338 res = self._dict_to_nvlist_to_dict(props)339 self._assertIntArrayDictsEqual(props, res)340 def test_explict_uint32_array_too_large_value(self):341 with self.assertRaises(OverflowError):342 props = {b"key": [uint32_t(0), uint32_t(2 ** 32)]}343 self._dict_to_nvlist_to_dict(props)344 def test_explict_uint32_array_negative_value(self):345 with self.assertRaises(OverflowError):346 props = {b"key": [uint32_t(0), uint32_t(-1)]}347 self._dict_to_nvlist_to_dict(props)348 def test_explict_uint16_array(self):349 props = {b"key": [uint16_t(0), uint16_t(1), uint16_t(2 ** 16 - 1)]}350 res = self._dict_to_nvlist_to_dict(props)351 self._assertIntArrayDictsEqual(props, res)352 def test_explict_uint16_array_too_large_value(self):353 with self.assertRaises(OverflowError):354 props = {b"key": [uint16_t(0), uint16_t(2 ** 16)]}355 self._dict_to_nvlist_to_dict(props)356 def test_explict_uint16_array_negative_value(self):357 with self.assertRaises(OverflowError):358 props = {b"key": [uint16_t(0), uint16_t(-1)]}359 self._dict_to_nvlist_to_dict(props)360 def test_explict_uint8_array(self):361 props = {b"key": [uint8_t(0), uint8_t(1), uint8_t(2 ** 8 - 1)]}362 res = self._dict_to_nvlist_to_dict(props)363 self._assertIntArrayDictsEqual(props, res)364 def test_explict_uint8_array_too_large_value(self):365 with self.assertRaises(OverflowError):366 props = {b"key": [uint8_t(0), uint8_t(2 ** 8)]}367 self._dict_to_nvlist_to_dict(props)368 def test_explict_uint8_array_negative_value(self):369 with self.assertRaises(OverflowError):370 props = {b"key": [uint8_t(0), uint8_t(-1)]}371 self._dict_to_nvlist_to_dict(props)372 def test_explict_byte_array(self):373 props = {b"key": [uchar_t(0), uchar_t(1), uchar_t(2 ** 8 - 1)]}374 res = self._dict_to_nvlist_to_dict(props)375 self._assertIntArrayDictsEqual(props, res)376 def test_explict_byte_array_too_large_value(self):377 with self.assertRaises(OverflowError):378 props = {b"key": [uchar_t(0), uchar_t(2 ** 8)]}379 self._dict_to_nvlist_to_dict(props)380 def test_explict_byte_array_negative_value(self):381 with self.assertRaises(OverflowError):382 props = {b"key": [uchar_t(0), uchar_t(-1)]}383 self._dict_to_nvlist_to_dict(props)384 def test_explict_int64_array(self):385 props = {b"key": [386 int64_t(0), int64_t(1), int64_t(2 ** 63 - 1), int64_t(-(2 ** 63))]}387 res = self._dict_to_nvlist_to_dict(props)388 self._assertIntArrayDictsEqual(props, res)389 def test_explict_int64_array_too_large_value(self):390 with self.assertRaises(OverflowError):391 props = {b"key": [int64_t(0), int64_t(2 ** 63)]}392 self._dict_to_nvlist_to_dict(props)393 def test_explict_int64_array_too_small_value(self):394 with self.assertRaises(OverflowError):395 props = {b"key": [int64_t(0), int64_t(-(2 ** 63) - 1)]}396 self._dict_to_nvlist_to_dict(props)397 def test_explict_int32_array(self):398 props = {b"key": [399 int32_t(0), int32_t(1), int32_t(2 ** 31 - 1), int32_t(-(2 ** 31))]}400 res = self._dict_to_nvlist_to_dict(props)401 self._assertIntArrayDictsEqual(props, res)402 def test_explict_int32_array_too_large_value(self):403 with self.assertRaises(OverflowError):404 props = {b"key": [int32_t(0), int32_t(2 ** 31)]}405 self._dict_to_nvlist_to_dict(props)406 def test_explict_int32_array_too_small_value(self):407 with self.assertRaises(OverflowError):408 props = {b"key": [int32_t(0), int32_t(-(2 ** 31) - 1)]}409 self._dict_to_nvlist_to_dict(props)410 def test_explict_int16_array(self):411 props = {b"key": [412 int16_t(0), int16_t(1), int16_t(2 ** 15 - 1), int16_t(-(2 ** 15))]}413 res = self._dict_to_nvlist_to_dict(props)414 self._assertIntArrayDictsEqual(props, res)415 def test_explict_int16_array_too_large_value(self):416 with self.assertRaises(OverflowError):417 props = {b"key": [int16_t(0), int16_t(2 ** 15)]}418 self._dict_to_nvlist_to_dict(props)419 def test_explict_int16_array_too_small_value(self):420 with self.assertRaises(OverflowError):421 props = {b"key": [int16_t(0), int16_t(-(2 ** 15) - 1)]}422 self._dict_to_nvlist_to_dict(props)423 def test_explict_int8_array(self):424 props = {b"key": [425 int8_t(0), int8_t(1), int8_t(2 ** 7 - 1), int8_t(-(2 ** 7))]}426 res = self._dict_to_nvlist_to_dict(props)427 self._assertIntArrayDictsEqual(props, res)428 def test_explict_int8_array_too_large_value(self):429 with self.assertRaises(OverflowError):430 props = {b"key": [int8_t(0), int8_t(2 ** 7)]}431 self._dict_to_nvlist_to_dict(props)432 def test_explict_int8_array_too_small_value(self):433 with self.assertRaises(OverflowError):434 props = {b"key": [int8_t(0), int8_t(-(2 ** 7) - 1)]}435 self._dict_to_nvlist_to_dict(props)436 def test_dict_array(self):437 props = {b"key": [{b"key": 1}, {b"key": None}, {b"key": {}}]}438 res = self._dict_to_nvlist_to_dict(props)439 self.assertEqual(props, res)440 def test_implicit_uint32_value(self):441 props = {b"rewind-request": 1}442 res = self._dict_to_nvlist_to_dict(props)443 self._assertIntDictsEqual(props, res)444 def test_implicit_uint32_max_value(self):445 props = {b"rewind-request": 2 ** 32 - 1}446 res = self._dict_to_nvlist_to_dict(props)447 self._assertIntDictsEqual(props, res)448 def test_implicit_uint32_too_large_value(self):449 with self.assertRaises(OverflowError):450 props = {b"rewind-request": 2 ** 32}451 self._dict_to_nvlist_to_dict(props)452 def test_implicit_uint32_negative_value(self):453 with self.assertRaises(OverflowError):454 props = {b"rewind-request": -1}455 self._dict_to_nvlist_to_dict(props)456 def test_implicit_int32_value(self):457 props = {b"pool_context": 1}458 res = self._dict_to_nvlist_to_dict(props)459 self._assertIntDictsEqual(props, res)460 def test_implicit_int32_max_value(self):461 props = {b"pool_context": 2 ** 31 - 1}462 res = self._dict_to_nvlist_to_dict(props)463 self._assertIntDictsEqual(props, res)464 def test_implicit_int32_min_value(self):465 props = {b"pool_context": -(2 ** 31)}466 res = self._dict_to_nvlist_to_dict(props)467 self._assertIntDictsEqual(props, res)468 def test_implicit_int32_too_large_value(self):469 with self.assertRaises(OverflowError):470 props = {b"pool_context": 2 ** 31}471 self._dict_to_nvlist_to_dict(props)472 def test_implicit_int32_too_small_value(self):473 with self.assertRaises(OverflowError):474 props = {b"pool_context": -(2 ** 31) - 1}475 self._dict_to_nvlist_to_dict(props)476 def test_complex_dict(self):477 props = {478 b"key1": b"str",479 b"key2": 10,480 b"key3": {481 b"skey1": True,482 b"skey2": None,483 b"skey3": [484 True,485 False,486 True487 ]488 },489 b"key4": [490 b"ab",491 b"bc"492 ],493 b"key5": [494 2 ** 64 - 1,495 1,496 2,497 3498 ],499 b"key6": [500 {501 b"skey71": b"a",502 b"skey72": b"b",503 },504 {505 b"skey71": b"c",506 b"skey72": b"d",507 },508 {509 b"skey71": b"e",510 b"skey72": b"f",511 }512 ],513 b"type": 2 ** 32 - 1,514 b"pool_context": -(2 ** 31)515 }516 res = self._dict_to_nvlist_to_dict(props)517 self.assertEqual(props, res)...
test_userdict.py
Source:test_userdict.py
...15 type2test = UserDict.IterableUserDict1617 def test_all(self):18 # Test constructors19 u = UserDict.UserDict()20 u0 = UserDict.UserDict(d0)21 u1 = UserDict.UserDict(d1)22 u2 = UserDict.IterableUserDict(d2)2324 uu = UserDict.UserDict(u)25 uu0 = UserDict.UserDict(u0)26 uu1 = UserDict.UserDict(u1)27 uu2 = UserDict.UserDict(u2)2829 # keyword arg constructor30 self.assertEqual(UserDict.UserDict(one=1, two=2), d2)31 # item sequence constructor32 self.assertEqual(UserDict.UserDict([('one',1), ('two',2)]), d2)33 with test_support.check_warnings((".*'dict'.*",34 PendingDeprecationWarning)):35 self.assertEqual(UserDict.UserDict(dict=[('one',1), ('two',2)]), d2)36 # both together37 self.assertEqual(UserDict.UserDict([('one',1), ('two',2)], two=3, three=5), d3)3839 # alternate constructor40 self.assertEqual(UserDict.UserDict.fromkeys('one two'.split()), d4)41 self.assertEqual(UserDict.UserDict().fromkeys('one two'.split()), d4)42 self.assertEqual(UserDict.UserDict.fromkeys('one two'.split(), 1), d5)43 self.assertEqual(UserDict.UserDict().fromkeys('one two'.split(), 1), d5)44 self.assertTrue(u1.fromkeys('one two'.split()) is not u1)45 self.assertIsInstance(u1.fromkeys('one two'.split()), UserDict.UserDict)46 self.assertIsInstance(u2.fromkeys('one two'.split()), UserDict.IterableUserDict)4748 # Test __repr__49 self.assertEqual(str(u0), str(d0))50 self.assertEqual(repr(u1), repr(d1))51 self.assertEqual(repr(u2), repr(d2))5253 # Test __cmp__ and __len__54 all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2]55 for a in all:56 for b in all:57 self.assertEqual(cmp(a, b), cmp(len(a), len(b)))5859 # Test __getitem__60 self.assertEqual(u2["one"], 1)61 self.assertRaises(KeyError, u1.__getitem__, "two")6263 # Test __setitem__64 u3 = UserDict.UserDict(u2)65 u3["two"] = 266 u3["three"] = 36768 # Test __delitem__69 del u3["three"]70 self.assertRaises(KeyError, u3.__delitem__, "three")7172 # Test clear73 u3.clear()74 self.assertEqual(u3, {})7576 # Test copy()77 u2a = u2.copy()78 self.assertEqual(u2a, u2)79 u2b = UserDict.UserDict(x=42, y=23)80 u2c = u2b.copy() # making a copy of a UserDict is special cased81 self.assertEqual(u2b, u2c)8283 class MyUserDict(UserDict.UserDict):84 def display(self): print self8586 m2 = MyUserDict(u2)87 m2a = m2.copy()88 self.assertEqual(m2a, m2)8990 # SF bug #476616 -- copy() of UserDict subclass shared data91 m2['foo'] = 'bar'92 self.assertNotEqual(m2a, m2)9394 # Test keys, items, values95 self.assertEqual(u2.keys(), d2.keys())96 self.assertEqual(u2.items(), d2.items())97 self.assertEqual(u2.values(), d2.values())9899 # Test has_key and "in".100 for i in u2.keys():101 self.assertIn(i, u2)102 self.assertEqual(i in u1, i in d1)103 self.assertEqual(i in u0, i in d0)104 with test_support.check_py3k_warnings():105 self.assertTrue(u2.has_key(i))106 self.assertEqual(u1.has_key(i), d1.has_key(i))107 self.assertEqual(u0.has_key(i), d0.has_key(i))108109 # Test update110 t = UserDict.UserDict()111 t.update(u2)112 self.assertEqual(t, u2)113 class Items:114 def items(self):115 return (("x", 42), ("y", 23))116 t = UserDict.UserDict()117 t.update(Items())118 self.assertEqual(t, {"x": 42, "y": 23})119120 # Test get121 for i in u2.keys():122 self.assertEqual(u2.get(i), u2[i])123 self.assertEqual(u1.get(i), d1.get(i))124 self.assertEqual(u0.get(i), d0.get(i))125126 # Test "in" iteration.127 for i in xrange(20):128 u2[i] = str(i)129 ikeys = []130 for k in u2:131 ikeys.append(k)132 keys = u2.keys()133 self.assertEqual(set(ikeys), set(keys))134135 # Test setdefault136 t = UserDict.UserDict()137 self.assertEqual(t.setdefault("x", 42), 42)138 self.assertTrue(t.has_key("x"))139 self.assertEqual(t.setdefault("x", 23), 42)140141 # Test pop142 t = UserDict.UserDict(x=42)143 self.assertEqual(t.pop("x"), 42)144 self.assertRaises(KeyError, t.pop, "x")145 self.assertEqual(t.pop("x", 1), 1)146 t["x"] = 42147 self.assertEqual(t.pop("x", 1), 42)148149 # Test popitem150 t = UserDict.UserDict(x=42)151 self.assertEqual(t.popitem(), ("x", 42))152 self.assertRaises(KeyError, t.popitem)153154 def test_init(self):155 for kw in 'self', 'other', 'iterable':156 self.assertEqual(list(UserDict.UserDict(**{kw: 42}).items()),157 [(kw, 42)])158 self.assertEqual(list(UserDict.UserDict({}, dict=42).items()),159 [('dict', 42)])160 self.assertEqual(list(UserDict.UserDict({}, dict=None).items()),161 [('dict', None)])162 with test_support.check_warnings((".*'dict'.*",163 PendingDeprecationWarning)):164 self.assertEqual(list(UserDict.UserDict(dict={'a': 42}).items()),165 [('a', 42)])166 self.assertRaises(TypeError, UserDict.UserDict, 42)167 self.assertRaises(TypeError, UserDict.UserDict, (), ())168 self.assertRaises(TypeError, UserDict.UserDict.__init__)169170 def test_update(self):171 for kw in 'self', 'other', 'iterable':172 d = UserDict.UserDict()173 d.update(**{kw: 42})174 self.assertEqual(list(d.items()), [(kw, 42)])175 d = UserDict.UserDict()176 with test_support.check_warnings((".*'dict'.*",177 PendingDeprecationWarning)):178 d.update(dict={'a': 42})179 self.assertEqual(list(d.items()), [('a', 42)])180 self.assertRaises(TypeError, UserDict.UserDict().update, 42)181 self.assertRaises(TypeError, UserDict.UserDict().update, {}, {})182 self.assertRaises(TypeError, UserDict.UserDict.update)183184 def test_missing(self):185 # Make sure UserDict doesn't have a __missing__ method186 self.assertEqual(hasattr(UserDict, "__missing__"), False)187 # Test several cases:188 # (D) subclass defines __missing__ method returning a value189 # (E) subclass defines __missing__ method raising RuntimeError190 # (F) subclass sets __missing__ instance variable (no effect)191 # (G) subclass doesn't define __missing__ at all192 class D(UserDict.UserDict):193 def __missing__(self, key):194 return 42195 d = D({1: 2, 3: 4})196 self.assertEqual(d[1], 2)197 self.assertEqual(d[3], 4)198 self.assertNotIn(2, d)199 self.assertNotIn(2, d.keys())200 self.assertEqual(d[2], 42)201 class E(UserDict.UserDict):202 def __missing__(self, key):203 raise RuntimeError(key)204 e = E()205 try:206 e[42]207 except RuntimeError, err:208 self.assertEqual(err.args, (42,))209 else:210 self.fail("e[42] didn't raise RuntimeError")211 class F(UserDict.UserDict):212 def __init__(self):213 # An instance variable __missing__ should have no effect214 self.__missing__ = lambda key: None215 UserDict.UserDict.__init__(self)216 f = F()217 try:218 f[42]219 except KeyError, err:220 self.assertEqual(err.args, (42,))221 else:222 self.fail("f[42] didn't raise KeyError")223 class G(UserDict.UserDict):224 pass225 g = G()226 try:227 g[42]228 except KeyError, err:229 self.assertEqual(err.args, (42,))230 else:231 self.fail("g[42] didn't raise KeyError")232233##########################234# Test Dict Mixin235236class SeqDict(UserDict.DictMixin):237 """Dictionary lookalike implemented with lists.238239 Used to test and demonstrate DictMixin240 """241 def __init__(self, other=None, **kwargs):242 self.keylist = []243 self.valuelist = []244 if other is not None:245 for (key, value) in other:246 self[key] = value247 for (key, value) in kwargs.iteritems():248 self[key] = value249 def __getitem__(self, key):250 try:251 i = self.keylist.index(key)252 except ValueError:253 raise KeyError254 return self.valuelist[i]255 def __setitem__(self, key, value):256 try:257 i = self.keylist.index(key)258 self.valuelist[i] = value259 except ValueError:260 self.keylist.append(key)261 self.valuelist.append(value)262 def __delitem__(self, key):263 try:264 i = self.keylist.index(key)265 except ValueError:266 raise KeyError267 self.keylist.pop(i)268 self.valuelist.pop(i)269 def keys(self):270 return list(self.keylist)271 def copy(self):272 d = self.__class__()273 for key, value in self.iteritems():274 d[key] = value275 return d276 @classmethod277 def fromkeys(cls, keys, value=None):278 d = cls()279 for key in keys:280 d[key] = value281 return d282283class UserDictMixinTest(mapping_tests.TestMappingProtocol):284 type2test = SeqDict285286 def test_all(self):287 ## Setup test and verify working of the test class288289 # check init290 s = SeqDict()291292 # exercise setitem293 s[10] = 'ten'294 s[20] = 'twenty'295 s[30] = 'thirty'296297 # exercise delitem298 del s[20]299 # check getitem and setitem300 self.assertEqual(s[10], 'ten')301 # check keys() and delitem302 self.assertEqual(s.keys(), [10, 30])303304 ## Now, test the DictMixin methods one by one305 # has_key306 self.assertTrue(s.has_key(10))307 self.assertTrue(not s.has_key(20))308309 # __contains__310 self.assertIn(10, s)311 self.assertNotIn(20, s)312313 # __iter__314 self.assertEqual([k for k in s], [10, 30])315316 # __len__317 self.assertEqual(len(s), 2)318319 # iteritems320 self.assertEqual(list(s.iteritems()), [(10,'ten'), (30, 'thirty')])321322 # iterkeys323 self.assertEqual(list(s.iterkeys()), [10, 30])324325 # itervalues326 self.assertEqual(list(s.itervalues()), ['ten', 'thirty'])327328 # values329 self.assertEqual(s.values(), ['ten', 'thirty'])330331 # items332 self.assertEqual(s.items(), [(10,'ten'), (30, 'thirty')])333334 # get335 self.assertEqual(s.get(10), 'ten')336 self.assertEqual(s.get(15,'fifteen'), 'fifteen')337 self.assertEqual(s.get(15), None)338339 # setdefault340 self.assertEqual(s.setdefault(40, 'forty'), 'forty')341 self.assertEqual(s.setdefault(10, 'null'), 'ten')342 del s[40]343344 # pop345 self.assertEqual(s.pop(10), 'ten')346 self.assertNotIn(10, s)347 s[10] = 'ten'348 self.assertEqual(s.pop("x", 1), 1)349 s["x"] = 42350 self.assertEqual(s.pop("x", 1), 42)351352 # popitem353 k, v = s.popitem()354 self.assertNotIn(k, s)355 s[k] = v356357 # clear358 s.clear()359 self.assertEqual(len(s), 0)360361 # empty popitem362 self.assertRaises(KeyError, s.popitem)363364 # update365 s.update({10: 'ten', 20:'twenty'})366 self.assertEqual(s[10], 'ten')367 self.assertEqual(s[20], 'twenty')368369 # cmp370 self.assertEqual(s, {10: 'ten', 20:'twenty'})371 t = SeqDict()372 t[20] = 'twenty'373 t[10] = 'ten'374 self.assertEqual(s, t)375376def test_main():377 test_support.run_unittest(378 UserDictTest,379 UserDictMixinTest380 )381382if __name__ == "__main__":
...
type-factory.service.ts
Source:type-factory.service.ts
...55 }56 /**57 * Create operator type from serialized data.58 */59 static fromDict(dict: OperatorTypeDict): OperatorType {60 const fromDict = OperatorTypeFactory.typeDeserializers.get(dict.operatorType);61 if (fromDict) {62 return fromDict(dict);63 } else {64 throw Error(`There is not factory method defined for operator »${dict.operatorType}«.`);65 }66 }67 protected static defaultDeserializers(): Map<Type, Deserializer> {68 const typeDeserializers = new Map();69 // typeDeserializers.set(70 // NumericAttributeFilterType.TYPE,71 // dict => NumericAttributeFilterType.fromDict(dict as NumericAttributeFilterTypeDict),72 // );73 // typeDeserializers.set(74 // TextualAttributeFilterType.TYPE,75 // dict => TextualAttributeFilterType.fromDict(dict as TextualAttributeFilterTypeDict),76 // );77 // typeDeserializers.set(78 // RasterValueExtractionType.TYPE,79 // dict => RasterValueExtractionType.fromDict(dict as RasterValueExtractionTypeDict),80 // );81 typeDeserializers.set(ExpressionType.TYPE, (dict) => ExpressionType.fromDict(dict as ExpressionTypeDict));82 // typeDeserializers.set(83 // ProjectionType.TYPE,84 // dict => ProjectionType.fromDict(dict as ProjectionTypeDict),85 // );86 // typeDeserializers.set(87 // GFBioSourceType.TYPE,88 // dict => GFBioSourceType.fromDict(dict as GFBioSourceTypeDict),89 // );90 // typeDeserializers.set(91 // RasterSourceType.TYPE,92 // dict => RasterSourceType.fromDict(dict as RasterSourceTypeDict),93 // );94 // typeDeserializers.set(95 // GdalSourceType.TYPE,96 // dict => GdalSourceType.fromDict(dict as GdalSourceTypeDict),97 // );98 // typeDeserializers.set(99 // OgrSourceType.TYPE,100 // dict => OgrSourceType.fromDict(dict as OgrSourceTypeDict),101 // );102 // typeDeserializers.set(103 // HistogramType.TYPE,104 // dict => HistogramType.fromDict(dict as HistogramTypeDict),105 // );106 // typeDeserializers.set(107 // RScriptType.TYPE,108 // dict => RScriptType.fromDict(dict as RScriptTypeDict),109 // );110 // typeDeserializers.set(111 // PointInPolygonFilterType.TYPE,112 // dict => PointInPolygonFilterType.fromDict(dict as PointInPolygonFilterTypeDict),113 // );114 // typeDeserializers.set(115 // WKTSourceType.TYPE,116 // dict => WKTSourceType.fromDict(dict as WKTSourceTypeDict),117 // );118 // typeDeserializers.set(119 // MsgRadianceType.TYPE,120 // dict => MsgRadianceType.fromDict(dict),121 // );122 // typeDeserializers.set(123 // MsgReflectanceType.TYPE,124 // dict => MsgReflectanceType.fromDict(dict as MsgReflectanceTypeDict),125 // );126 // typeDeserializers.set(127 // MsgSolarangleType.TYPE,128 // dict => MsgSolarangleType.fromDict(dict as MsgSolarangleTypeDict),129 // );130 // typeDeserializers.set(131 // MsgTemperatureType.TYPE,132 // dict => MsgTemperatureType.fromDict(dict),133 // );134 // typeDeserializers.set(135 // MsgPansharpenType.TYPE,136 // dict => MsgPansharpenType.fromDict(dict as MsgPansharpenTypeDict),137 // );138 // typeDeserializers.set(139 // MsgCo2CorrectionType.TYPE,140 // dict => MsgCo2CorrectionType.fromDict(dict),141 // );142 // typeDeserializers.set(143 // MsgSofosGccThermalThresholdType.TYPE,144 // dict => MsgSofosGccThermalThresholdType.fromDict(dict),145 // );146 // typeDeserializers.set(147 // CsvSourceType.TYPE,148 // dict => CsvSourceType.fromDict(dict as CsvSourceTypeDict),149 // );150 // typeDeserializers.set(151 // ClassificationType.TYPE,152 // dict => ClassificationType.fromDict(dict as ClassificationTypeDict),153 // );154 // typeDeserializers.set(155 // FeatureCollectionDBSourceType.TYPE,156 // dict => FeatureCollectionDBSourceType.fromDict(dict as FeatureCollectionDBSourceTypeDict),157 // );158 // typeDeserializers.set(159 // ScatterPlotType.TYPE,160 // dict => ScatterPlotType.fromDict(dict as ScatterPlotTypeDict),161 // );162 // typeDeserializers.set(163 // BoxPlotType.TYPE,164 // dict => BoxPlotType.fromDict(dict as BoxPlotTypeDict),165 // );166 // typeDeserializers.set(167 // PieChartType.TYPE,168 // dict => PieChartType.fromDict(dict as PieChartTypeDict),169 // );170 // typeDeserializers.set(171 // RasterizePolygonType.TYPE,172 // dict => RasterizePolygonType.fromDict(dict as RasterizePolygonTypeDict),173 // );174 // typeDeserializers.set(175 // HeatmapType.TYPE,176 // dict => HeatmapType.fromDict(dict as HeatmapTypeDict),177 // );178 // typeDeserializers.set(179 // StatisticsType.TYPE,180 // dict => StatisticsType.fromDict(dict as StatisticsTypeDict),181 // );182 // typeDeserializers.set(183 // TimePlotType.TYPE,184 // dict => TimePlotType.fromDict(dict as TimePlotTypeDict),185 // );186 // typeDeserializers.set(187 // RgbaCompositeType.TYPE,188 // dict => RgbaCompositeType.fromDict(dict as RgbaCompositeTypeDict),189 // );190 // typeDeserializers.set(191 // ChronicleDBSourceType.TYPE,192 // dict => ChronicleDBSourceType.fromDict(dict as ChronicleDBSourceTypeDict),193 // );194 // typeDeserializers.set(195 // OgrRawSourceType.TYPE,196 // dict => OgrRawSourceType.fromDict(dict as OgrRawSourceTypeDict),197 // );198 return typeDeserializers;199 }...
backend.model.ts
Source:backend.model.ts
...165 error: string;166 message: string;167}168export interface ToDict<T> {169 toDict(): T;170}171export interface RegisterWorkflowResultDict {172 id: UUID;173}174export interface WorkflowDict {175 type: 'Vector' | 'Raster' | 'Plot';176 operator: OperatorDict | SourceOperatorDict;177}178export interface OperatorDict {179 type: string;180 params: OperatorParams;181 vector_sources?: Array<OperatorDict | SourceOperatorDict>;182 raster_sources?: Array<OperatorDict | SourceOperatorDict>;183}...
script.py
Source:script.py
...132 order = True133 else:134 order = False135 if order:136 ordered_dict = OrderedDict(reversed(dict_folders.items()))137 else:138 ordered_dict = OrderedDict(sorted(dict_folders.items()))139 return ordered_dict140def render_dict(print_dict):141 """Print dict before hash"""142 print('')143 for key, value in print_dict.items():144 print(key, 'bytes')145 for item in value:146 print(item)147 print('')148def some_requirements():149 """for jb bugs."""150 os.system("mv module/root_folder/files/stage/src/reviewSlider.js module/root_folder/files/stage/src/reviewslider.js")151 os.system("mv module/root_folder/files/stage/src/toggleMiniMenu.js module/root_folder/files/stage/src/toggleminimenu.js")152def menu():...
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Barack Obama');3page.get(function(err, data) {4 console.log(data);5 console.log(data.infobox);6 console.log(data.infobox.birth_date);7 console.log(data.infobox.birth_place);8 console.log(data.infobox.birth_name);9 console.log(data.infobox.residence);10 console.log(data.infobox.office);11 console.log(data.infobox.party);12 console.log(data.infobox.spouse);13 console.log(data.infobox.children);14 console.log(data.infobox.religion);15 console.log(data.infobox.alma_mater);16 console.log(data.infobox.profession);17 console.log(data.infobox.website);18});19var wptools = require('wptools');20var page = wptools.page('Barack Obama');21page.get(function(err, data) {22 console.log(data);23 console.log(data.infobox);24 console.log(data.infobox.birth_date);25 console.log(data.infobox.birth_place);26 console.log(data.infobox.birth_name);27 console.log(data.infobox.residence);28 console.log(data.infobox.office);29 console.log(data.infobox.party);30 console.log(data.infobox.spouse);31 console.log(data.infobox.children);32 console.log(data.infobox.religion);33 console.log(data.infobox.alma_mater);34 console.log(data.infobox.profession);35 console.log(data.infobox.website);36});37var wptools = require('wptools');38var page = wptools.page('Barack Obama');39page.get(function(err, data) {40 console.log(data);41 console.log(data.infobox);42 console.log(data.infobox.birth_date);43 console.log(data.infobox.birth_place);44 console.log(data.infobox.birth_name);45 console.log(data.infobox.residence);46 console.log(data.infobox.office);47 console.log(data.infobox.party);48 console.log(data.infobox.spouse);49 console.log(data.infobox.children);50 console.log(data.infobox.religion);51 console.log(data.infobox.alma_mater);52 console.log(data.infobox.profession);53 console.log(data.infobox.website);54});
Using AI Code Generation
1var wptools = require('wptools');2var dict = wptools.getDict('test');3dict.set('key', 'value', function(err) {4 if (err) {5 console.log('Error setting key');6 } else {7 dict.get('key', function(err, val) {8 if (err) {9 console.log('Error getting key');10 } else {11 console.log('Value of key is ' + val);12 }13 });14 }15});16var wptools = require('wptools');17var dict = wptools.getDict('test');18dict.set('key', 'value', function(err) {19 if (err) {20 console.log('Error setting key');21 } else {22 dict.get('key', function(err, val) {23 if (err) {24 console.log('Error getting key');25 } else {26 console.log('Value of key is ' + val);27 }28 });29 }30});31var wptools = require('wptools');32var dict = wptools.getDict('test');33dict.set('key', 'value', function(err) {34 if (err) {35 console.log('Error setting key');36 } else {37 dict.get('key', function(err, val) {38 if (err) {39 console.log('Error getting key');40 } else {41 console.log('Value of key is ' + val);42 }43 });44 }45});46var wptools = require('wptools');47var dict = wptools.getDict('test');48dict.set('key', 'value', function(err) {49 if (err) {50 console.log('Error setting key');51 } else {52 dict.get('key', function(err, val) {53 if (err) {54 console.log('Error getting key');55 } else {56 console.log('Value of key is ' + val);57 }58 });59 }60});61var wptools = require('wptools');62var dict = wptools.getDict('test');63dict.set('
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3wptools.page('apple').get(function(err, resp) {4 fs.writeFile('output.txt', JSON.stringify(resp), function(err) {5 if (err) {6 return console.log(err);7 }8 console.log('The file was saved!');9 });10});
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var text = fs.readFileSync('input.txt', 'utf8');4var textByLine = text.split("5");6var arr = [];7for (var i = 0; i < textByLine.length; i++) {8 arr[i] = textByLine[i].split("\t");9}10var result = [];11for (var i = 0; i < arr.length; i++) {12 var dict = wptools.getTemplate(arr[i][1], arr[i][0]);13 result.push(dict);14}15for (var i = 0; i < result.length; i++) {16 console.log(result[i]);17}18var wptools = require('wptools');19var fs = require('fs');20var text = fs.readFileSync('input.txt', 'utf8');21var textByLine = text.split("22");23var arr = [];24for (var i = 0; i < textByLine.length; i++) {25 arr[i] = textByLine[i].split("\t");26}27var result = [];28for (var i = 0; i < arr.length; i++) {29 var dict = wptools.getTemplate(arr[i][1], arr[i][0]);30 result.push(dict);31}32for (var i = 0; i < result.length; i++) {33 console.log(result[i]);34}35var wptools = require('w
Using AI Code Generation
1var wptools = require('wptools');2var dict = new wptools.dict();3dict.get('dog',function(err, data) {4 console.log(data);5});6var wptools = require('wptools');7var wiki = new wptools.wiki();8wiki.get('dog',function(err, data) {9 console.log(data);10});11var wptools = require('wptools');12var category = new wptools.category();13category.get('dog',function(err, data) {14 console.log(data);15});16var wptools = require('wptools');17var category = new wptools.category();18category.get('dog',function(err, data) {19 console.log(data);20});21var wptools = require('wptools');22var category = new wptools.category();23category.get('dog',function(err, data) {24 console.log(data);25});26var wptools = require('wptools');27var category = new wptools.category();28category.get('dog',function(err, data) {29 console.log(data);30});31var wptools = require('wptools');32var category = new wptools.category();33category.get('dog',function(err, data) {34 console.log(data);35});36var wptools = require('wptools');37var category = new wptools.category();38category.get('dog',function(err, data) {39 console.log(data);40});41var wptools = require('wptools');42var category = new wptools.category();43category.get('dog',function(err, data) {44 console.log(data);45});46var wptools = require('wptools
Using AI Code Generation
1var dict = require('wptools').dict;2dict('test', function(err, data) {3 if (err) {4 console.log('Error: ' + err);5 }6 else {7 console.log(data);8 }9});10var dict = require('wptools').dict;11dict('test', function(err, data) {12 if (err) {13 console.log('Error: ' + err);14 }15 else {16 console.log(data);17 }18});19var dict = require('wptools').dict;20dict('test', function(err, data) {21 if (err) {22 console.log('Error: ' + err);23 }24 else {25 console.log(data);26 }27});28var dict = require('wptools').dict;29dict('test', function(err, data) {30 if (err) {31 console.log('Error: ' + err);32 }33 else {34 console.log(data);35 }36});37var dict = require('wptools').dict;38dict('test', function(err, data) {39 if (err) {40 console.log('Error: ' + err);41 }42 else {43 console.log(data);44 }45});46var dict = require('wptools').dict;47dict('test', function(err, data) {48 if (err) {49 console.log('Error: ' + err);50 }51 else {52 console.log(data);53 }54});55var dict = require('wptools').dict;56dict('test', function(err, data) {57 if (err) {58 console.log('Error: ' + err);59 }60 else {61 console.log(data);62 }63});64var dict = require('wptools').dict;65dict('test', function
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!