How to use deepCopy method in wpt

Best JavaScript code snippet using wpt

test_copy.py

Source:test_copy.py Github

copy

Full Screen

1"""Unit tests for the copy module."""2import copy3import copyreg4import weakref5from operator import le, lt, ge, gt, eq, ne6import unittest7from test import support8order_comparisons = le, lt, ge, gt9equality_comparisons = eq, ne10comparisons = order_comparisons + equality_comparisons11class TestCopy(unittest.TestCase):12 # Attempt full line coverage of copy.py from top to bottom13 def test_exceptions(self):14 self.assertIs(copy.Error, copy.error)15 self.assertTrue(issubclass(copy.Error, Exception))16 # The copy() method17 def test_copy_basic(self):18 x = 4219 y = copy.copy(x)20 self.assertEqual(x, y)21 def test_copy_copy(self):22 class C(object):23 def __init__(self, foo):24 self.foo = foo25 def __copy__(self):26 return C(self.foo)27 x = C(42)28 y = copy.copy(x)29 self.assertEqual(y.__class__, x.__class__)30 self.assertEqual(y.foo, x.foo)31 def test_copy_registry(self):32 class C(object):33 def __new__(cls, foo):34 obj = object.__new__(cls)35 obj.foo = foo36 return obj37 def pickle_C(obj):38 return (C, (obj.foo,))39 x = C(42)40 self.assertRaises(TypeError, copy.copy, x)41 copyreg.pickle(C, pickle_C, C)42 y = copy.copy(x)43 def test_copy_reduce_ex(self):44 class C(object):45 def __reduce_ex__(self, proto):46 c.append(1)47 return ""48 def __reduce__(self):49 self.fail("shouldn't call this")50 c = []51 x = C()52 y = copy.copy(x)53 self.assertIs(y, x)54 self.assertEqual(c, [1])55 def test_copy_reduce(self):56 class C(object):57 def __reduce__(self):58 c.append(1)59 return ""60 c = []61 x = C()62 y = copy.copy(x)63 self.assertIs(y, x)64 self.assertEqual(c, [1])65 def test_copy_cant(self):66 class C(object):67 def __getattribute__(self, name):68 if name.startswith("__reduce"):69 raise AttributeError(name)70 return object.__getattribute__(self, name)71 x = C()72 self.assertRaises(copy.Error, copy.copy, x)73 # Type-specific _copy_xxx() methods74 def test_copy_atomic(self):75 class Classic:76 pass77 class NewStyle(object):78 pass79 def f():80 pass81 tests = [None, 42, 2**100, 3.14, True, False, 1j,82 "hello", "hello\u1234", f.__code__,83 NewStyle, range(10), Classic, max]84 for x in tests:85 self.assertIs(copy.copy(x), x)86 def test_copy_list(self):87 x = [1, 2, 3]88 self.assertEqual(copy.copy(x), x)89 def test_copy_tuple(self):90 x = (1, 2, 3)91 self.assertEqual(copy.copy(x), x)92 def test_copy_dict(self):93 x = {"foo": 1, "bar": 2}94 self.assertEqual(copy.copy(x), x)95 def test_copy_inst_vanilla(self):96 class C:97 def __init__(self, foo):98 self.foo = foo99 def __eq__(self, other):100 return self.foo == other.foo101 x = C(42)102 self.assertEqual(copy.copy(x), x)103 def test_copy_inst_copy(self):104 class C:105 def __init__(self, foo):106 self.foo = foo107 def __copy__(self):108 return C(self.foo)109 def __eq__(self, other):110 return self.foo == other.foo111 x = C(42)112 self.assertEqual(copy.copy(x), x)113 def test_copy_inst_getinitargs(self):114 class C:115 def __init__(self, foo):116 self.foo = foo117 def __getinitargs__(self):118 return (self.foo,)119 def __eq__(self, other):120 return self.foo == other.foo121 x = C(42)122 self.assertEqual(copy.copy(x), x)123 def test_copy_inst_getstate(self):124 class C:125 def __init__(self, foo):126 self.foo = foo127 def __getstate__(self):128 return {"foo": self.foo}129 def __eq__(self, other):130 return self.foo == other.foo131 x = C(42)132 self.assertEqual(copy.copy(x), x)133 def test_copy_inst_setstate(self):134 class C:135 def __init__(self, foo):136 self.foo = foo137 def __setstate__(self, state):138 self.foo = state["foo"]139 def __eq__(self, other):140 return self.foo == other.foo141 x = C(42)142 self.assertEqual(copy.copy(x), x)143 def test_copy_inst_getstate_setstate(self):144 class C:145 def __init__(self, foo):146 self.foo = foo147 def __getstate__(self):148 return self.foo149 def __setstate__(self, state):150 self.foo = state151 def __eq__(self, other):152 return self.foo == other.foo153 x = C(42)154 self.assertEqual(copy.copy(x), x)155 # The deepcopy() method156 def test_deepcopy_basic(self):157 x = 42158 y = copy.deepcopy(x)159 self.assertEqual(y, x)160 def test_deepcopy_memo(self):161 # Tests of reflexive objects are under type-specific sections below.162 # This tests only repetitions of objects.163 x = []164 x = [x, x]165 y = copy.deepcopy(x)166 self.assertEqual(y, x)167 self.assertIsNot(y, x)168 self.assertIsNot(y[0], x[0])169 self.assertIs(y[0], y[1])170 def test_deepcopy_issubclass(self):171 # XXX Note: there's no way to test the TypeError coming out of172 # issubclass() -- this can only happen when an extension173 # module defines a "type" that doesn't formally inherit from174 # type.175 class Meta(type):176 pass177 class C(metaclass=Meta):178 pass179 self.assertEqual(copy.deepcopy(C), C)180 def test_deepcopy_deepcopy(self):181 class C(object):182 def __init__(self, foo):183 self.foo = foo184 def __deepcopy__(self, memo=None):185 return C(self.foo)186 x = C(42)187 y = copy.deepcopy(x)188 self.assertEqual(y.__class__, x.__class__)189 self.assertEqual(y.foo, x.foo)190 def test_deepcopy_registry(self):191 class C(object):192 def __new__(cls, foo):193 obj = object.__new__(cls)194 obj.foo = foo195 return obj196 def pickle_C(obj):197 return (C, (obj.foo,))198 x = C(42)199 self.assertRaises(TypeError, copy.deepcopy, x)200 copyreg.pickle(C, pickle_C, C)201 y = copy.deepcopy(x)202 def test_deepcopy_reduce_ex(self):203 class C(object):204 def __reduce_ex__(self, proto):205 c.append(1)206 return ""207 def __reduce__(self):208 self.fail("shouldn't call this")209 c = []210 x = C()211 y = copy.deepcopy(x)212 self.assertIs(y, x)213 self.assertEqual(c, [1])214 def test_deepcopy_reduce(self):215 class C(object):216 def __reduce__(self):217 c.append(1)218 return ""219 c = []220 x = C()221 y = copy.deepcopy(x)222 self.assertIs(y, x)223 self.assertEqual(c, [1])224 def test_deepcopy_cant(self):225 class C(object):226 def __getattribute__(self, name):227 if name.startswith("__reduce"):228 raise AttributeError(name)229 return object.__getattribute__(self, name)230 x = C()231 self.assertRaises(copy.Error, copy.deepcopy, x)232 # Type-specific _deepcopy_xxx() methods233 def test_deepcopy_atomic(self):234 class Classic:235 pass236 class NewStyle(object):237 pass238 def f():239 pass240 tests = [None, 42, 2**100, 3.14, True, False, 1j,241 "hello", "hello\u1234", f.__code__,242 NewStyle, range(10), Classic, max]243 for x in tests:244 self.assertIs(copy.deepcopy(x), x)245 def test_deepcopy_list(self):246 x = [[1, 2], 3]247 y = copy.deepcopy(x)248 self.assertEqual(y, x)249 self.assertIsNot(x, y)250 self.assertIsNot(x[0], y[0])251 def test_deepcopy_reflexive_list(self):252 x = []253 x.append(x)254 y = copy.deepcopy(x)255 for op in comparisons:256 self.assertRaises(RuntimeError, op, y, x)257 self.assertIsNot(y, x)258 self.assertIs(y[0], y)259 self.assertEqual(len(y), 1)260 def test_deepcopy_empty_tuple(self):261 x = ()262 y = copy.deepcopy(x)263 self.assertIs(x, y)264 def test_deepcopy_tuple(self):265 x = ([1, 2], 3)266 y = copy.deepcopy(x)267 self.assertEqual(y, x)268 self.assertIsNot(x, y)269 self.assertIsNot(x[0], y[0])270 def test_deepcopy_tuple_of_immutables(self):271 x = ((1, 2), 3)272 y = copy.deepcopy(x)273 self.assertIs(x, y)274 def test_deepcopy_reflexive_tuple(self):275 x = ([],)276 x[0].append(x)277 y = copy.deepcopy(x)278 for op in comparisons:279 self.assertRaises(RuntimeError, op, y, x)280 self.assertIsNot(y, x)281 self.assertIsNot(y[0], x[0])282 self.assertIs(y[0][0], y)283 def test_deepcopy_dict(self):284 x = {"foo": [1, 2], "bar": 3}285 y = copy.deepcopy(x)286 self.assertEqual(y, x)287 self.assertIsNot(x, y)288 self.assertIsNot(x["foo"], y["foo"])289 def test_deepcopy_reflexive_dict(self):290 x = {}291 x['foo'] = x292 y = copy.deepcopy(x)293 for op in order_comparisons:294 self.assertRaises(TypeError, op, y, x)295 for op in equality_comparisons:296 self.assertRaises(RuntimeError, op, y, x)297 self.assertIsNot(y, x)298 self.assertIs(y['foo'], y)299 self.assertEqual(len(y), 1)300 def test_deepcopy_keepalive(self):301 memo = {}302 x = []303 y = copy.deepcopy(x, memo)304 self.assertIs(memo[id(memo)][0], x)305 def test_deepcopy_dont_memo_immutable(self):306 memo = {}307 x = [1, 2, 3, 4]308 y = copy.deepcopy(x, memo)309 self.assertEqual(y, x)310 # There's the entry for the new list, and the keep alive.311 self.assertEqual(len(memo), 2)312 memo = {}313 x = [(1, 2)]314 y = copy.deepcopy(x, memo)315 self.assertEqual(y, x)316 # Tuples with immutable contents are immutable for deepcopy.317 self.assertEqual(len(memo), 2)318 def test_deepcopy_inst_vanilla(self):319 class C:320 def __init__(self, foo):321 self.foo = foo322 def __eq__(self, other):323 return self.foo == other.foo324 x = C([42])325 y = copy.deepcopy(x)326 self.assertEqual(y, x)327 self.assertIsNot(y.foo, x.foo)328 def test_deepcopy_inst_deepcopy(self):329 class C:330 def __init__(self, foo):331 self.foo = foo332 def __deepcopy__(self, memo):333 return C(copy.deepcopy(self.foo, memo))334 def __eq__(self, other):335 return self.foo == other.foo336 x = C([42])337 y = copy.deepcopy(x)338 self.assertEqual(y, x)339 self.assertIsNot(y, x)340 self.assertIsNot(y.foo, x.foo)341 def test_deepcopy_inst_getinitargs(self):342 class C:343 def __init__(self, foo):344 self.foo = foo345 def __getinitargs__(self):346 return (self.foo,)347 def __eq__(self, other):348 return self.foo == other.foo349 x = C([42])350 y = copy.deepcopy(x)351 self.assertEqual(y, x)352 self.assertIsNot(y, x)353 self.assertIsNot(y.foo, x.foo)354 def test_deepcopy_inst_getstate(self):355 class C:356 def __init__(self, foo):357 self.foo = foo358 def __getstate__(self):359 return {"foo": self.foo}360 def __eq__(self, other):361 return self.foo == other.foo362 x = C([42])363 y = copy.deepcopy(x)364 self.assertEqual(y, x)365 self.assertIsNot(y, x)366 self.assertIsNot(y.foo, x.foo)367 def test_deepcopy_inst_setstate(self):368 class C:369 def __init__(self, foo):370 self.foo = foo371 def __setstate__(self, state):372 self.foo = state["foo"]373 def __eq__(self, other):374 return self.foo == other.foo375 x = C([42])376 y = copy.deepcopy(x)377 self.assertEqual(y, x)378 self.assertIsNot(y, x)379 self.assertIsNot(y.foo, x.foo)380 def test_deepcopy_inst_getstate_setstate(self):381 class C:382 def __init__(self, foo):383 self.foo = foo384 def __getstate__(self):385 return self.foo386 def __setstate__(self, state):387 self.foo = state388 def __eq__(self, other):389 return self.foo == other.foo390 x = C([42])391 y = copy.deepcopy(x)392 self.assertEqual(y, x)393 self.assertIsNot(y, x)394 self.assertIsNot(y.foo, x.foo)395 def test_deepcopy_reflexive_inst(self):396 class C:397 pass398 x = C()399 x.foo = x400 y = copy.deepcopy(x)401 self.assertIsNot(y, x)402 self.assertIs(y.foo, y)403 # _reconstruct()404 def test_reconstruct_string(self):405 class C(object):406 def __reduce__(self):407 return ""408 x = C()409 y = copy.copy(x)410 self.assertIs(y, x)411 y = copy.deepcopy(x)412 self.assertIs(y, x)413 def test_reconstruct_nostate(self):414 class C(object):415 def __reduce__(self):416 return (C, ())417 x = C()418 x.foo = 42419 y = copy.copy(x)420 self.assertIs(y.__class__, x.__class__)421 y = copy.deepcopy(x)422 self.assertIs(y.__class__, x.__class__)423 def test_reconstruct_state(self):424 class C(object):425 def __reduce__(self):426 return (C, (), self.__dict__)427 def __eq__(self, other):428 return self.__dict__ == other.__dict__429 x = C()430 x.foo = [42]431 y = copy.copy(x)432 self.assertEqual(y, x)433 y = copy.deepcopy(x)434 self.assertEqual(y, x)435 self.assertIsNot(y.foo, x.foo)436 def test_reconstruct_state_setstate(self):437 class C(object):438 def __reduce__(self):439 return (C, (), self.__dict__)440 def __setstate__(self, state):441 self.__dict__.update(state)442 def __eq__(self, other):443 return self.__dict__ == other.__dict__444 x = C()445 x.foo = [42]446 y = copy.copy(x)447 self.assertEqual(y, x)448 y = copy.deepcopy(x)449 self.assertEqual(y, x)450 self.assertIsNot(y.foo, x.foo)451 def test_reconstruct_reflexive(self):452 class C(object):453 pass454 x = C()455 x.foo = x456 y = copy.deepcopy(x)457 self.assertIsNot(y, x)458 self.assertIs(y.foo, y)459 # Additions for Python 2.3 and pickle protocol 2460 def test_reduce_4tuple(self):461 class C(list):462 def __reduce__(self):463 return (C, (), self.__dict__, iter(self))464 def __eq__(self, other):465 return (list(self) == list(other) and466 self.__dict__ == other.__dict__)467 x = C([[1, 2], 3])468 y = copy.copy(x)469 self.assertEqual(x, y)470 self.assertIsNot(x, y)471 self.assertIs(x[0], y[0])472 y = copy.deepcopy(x)473 self.assertEqual(x, y)474 self.assertIsNot(x, y)475 self.assertIsNot(x[0], y[0])476 def test_reduce_5tuple(self):477 class C(dict):478 def __reduce__(self):479 return (C, (), self.__dict__, None, self.items())480 def __eq__(self, other):481 return (dict(self) == dict(other) and482 self.__dict__ == other.__dict__)483 x = C([("foo", [1, 2]), ("bar", 3)])484 y = copy.copy(x)485 self.assertEqual(x, y)486 self.assertIsNot(x, y)487 self.assertIs(x["foo"], y["foo"])488 y = copy.deepcopy(x)489 self.assertEqual(x, y)490 self.assertIsNot(x, y)491 self.assertIsNot(x["foo"], y["foo"])492 def test_copy_slots(self):493 class C(object):494 __slots__ = ["foo"]495 x = C()496 x.foo = [42]497 y = copy.copy(x)498 self.assertIs(x.foo, y.foo)499 def test_deepcopy_slots(self):500 class C(object):501 __slots__ = ["foo"]502 x = C()503 x.foo = [42]504 y = copy.deepcopy(x)505 self.assertEqual(x.foo, y.foo)506 self.assertIsNot(x.foo, y.foo)507 def test_deepcopy_dict_subclass(self):508 class C(dict):509 def __init__(self, d=None):510 if not d:511 d = {}512 self._keys = list(d.keys())513 super().__init__(d)514 def __setitem__(self, key, item):515 super().__setitem__(key, item)516 if key not in self._keys:517 self._keys.append(key)518 x = C(d={'foo':0})519 y = copy.deepcopy(x)520 self.assertEqual(x, y)521 self.assertEqual(x._keys, y._keys)522 self.assertIsNot(x, y)523 x['bar'] = 1524 self.assertNotEqual(x, y)525 self.assertNotEqual(x._keys, y._keys)526 def test_copy_list_subclass(self):527 class C(list):528 pass529 x = C([[1, 2], 3])530 x.foo = [4, 5]531 y = copy.copy(x)532 self.assertEqual(list(x), list(y))533 self.assertEqual(x.foo, y.foo)534 self.assertIs(x[0], y[0])535 self.assertIs(x.foo, y.foo)536 def test_deepcopy_list_subclass(self):537 class C(list):538 pass539 x = C([[1, 2], 3])540 x.foo = [4, 5]541 y = copy.deepcopy(x)542 self.assertEqual(list(x), list(y))543 self.assertEqual(x.foo, y.foo)544 self.assertIsNot(x[0], y[0])545 self.assertIsNot(x.foo, y.foo)546 def test_copy_tuple_subclass(self):547 class C(tuple):548 pass549 x = C([1, 2, 3])550 self.assertEqual(tuple(x), (1, 2, 3))551 y = copy.copy(x)552 self.assertEqual(tuple(y), (1, 2, 3))553 def test_deepcopy_tuple_subclass(self):554 class C(tuple):555 pass556 x = C([[1, 2], 3])557 self.assertEqual(tuple(x), ([1, 2], 3))558 y = copy.deepcopy(x)559 self.assertEqual(tuple(y), ([1, 2], 3))560 self.assertIsNot(x, y)561 self.assertIsNot(x[0], y[0])562 def test_getstate_exc(self):563 class EvilState(object):564 def __getstate__(self):565 raise ValueError("ain't got no stickin' state")566 self.assertRaises(ValueError, copy.copy, EvilState())567 def test_copy_function(self):568 self.assertEqual(copy.copy(global_foo), global_foo)569 def foo(x, y): return x+y570 self.assertEqual(copy.copy(foo), foo)571 bar = lambda: None572 self.assertEqual(copy.copy(bar), bar)573 def test_deepcopy_function(self):574 self.assertEqual(copy.deepcopy(global_foo), global_foo)575 def foo(x, y): return x+y576 self.assertEqual(copy.deepcopy(foo), foo)577 bar = lambda: None578 self.assertEqual(copy.deepcopy(bar), bar)579 def _check_weakref(self, _copy):580 class C(object):581 pass582 obj = C()583 x = weakref.ref(obj)584 y = _copy(x)585 self.assertIs(y, x)586 del obj587 y = _copy(x)588 self.assertIs(y, x)589 def test_copy_weakref(self):590 self._check_weakref(copy.copy)591 def test_deepcopy_weakref(self):592 self._check_weakref(copy.deepcopy)593 def _check_copy_weakdict(self, _dicttype):594 class C(object):595 pass596 a, b, c, d = [C() for i in range(4)]597 u = _dicttype()598 u[a] = b599 u[c] = d600 v = copy.copy(u)601 self.assertIsNot(v, u)602 self.assertEqual(v, u)603 self.assertEqual(v[a], b)604 self.assertEqual(v[c], d)605 self.assertEqual(len(v), 2)606 del c, d607 self.assertEqual(len(v), 1)608 x, y = C(), C()609 # The underlying containers are decoupled610 v[x] = y611 self.assertNotIn(x, u)612 def test_copy_weakkeydict(self):613 self._check_copy_weakdict(weakref.WeakKeyDictionary)614 def test_copy_weakvaluedict(self):615 self._check_copy_weakdict(weakref.WeakValueDictionary)616 def test_deepcopy_weakkeydict(self):617 class C(object):618 def __init__(self, i):619 self.i = i620 a, b, c, d = [C(i) for i in range(4)]621 u = weakref.WeakKeyDictionary()622 u[a] = b623 u[c] = d624 # Keys aren't copied, values are625 v = copy.deepcopy(u)626 self.assertNotEqual(v, u)627 self.assertEqual(len(v), 2)628 self.assertIsNot(v[a], b)629 self.assertIsNot(v[c], d)630 self.assertEqual(v[a].i, b.i)631 self.assertEqual(v[c].i, d.i)632 del c633 self.assertEqual(len(v), 1)634 def test_deepcopy_weakvaluedict(self):635 class C(object):636 def __init__(self, i):637 self.i = i638 a, b, c, d = [C(i) for i in range(4)]639 u = weakref.WeakValueDictionary()640 u[a] = b641 u[c] = d642 # Keys are copied, values aren't643 v = copy.deepcopy(u)644 self.assertNotEqual(v, u)645 self.assertEqual(len(v), 2)646 (x, y), (z, t) = sorted(v.items(), key=lambda pair: pair[0].i)647 self.assertIsNot(x, a)648 self.assertEqual(x.i, a.i)649 self.assertIs(y, b)650 self.assertIsNot(z, c)651 self.assertEqual(z.i, c.i)652 self.assertIs(t, d)653 del x, y, z, t654 del d655 self.assertEqual(len(v), 1)656 def test_deepcopy_bound_method(self):657 class Foo(object):658 def m(self):659 pass660 f = Foo()661 f.b = f.m662 g = copy.deepcopy(f)663 self.assertEqual(g.m, g.b)664 self.assertIs(g.b.__self__, g)665 g.b()666def global_foo(x, y): return x+y667def test_main():668 support.run_unittest(TestCopy)669if __name__ == "__main__":...

Full Screen

Full Screen

copy.py

Source:copy.py Github

copy

Full Screen

1"""Generic (shallow and deep) copying operations.2Interface summary:3 import copy4 x = copy.copy(y) # make a shallow copy of y5 x = copy.deepcopy(y) # make a deep copy of y6For module specific errors, copy.Error is raised.7The difference between shallow and deep copying is only relevant for8compound objects (objects that contain other objects, like lists or9class instances).10- A shallow copy constructs a new compound object and then (to the11 extent possible) inserts *the same objects* into it that the12 original contains.13- A deep copy constructs a new compound object and then, recursively,14 inserts *copies* into it of the objects found in the original.15Two problems often exist with deep copy operations that don't exist16with shallow copy operations:17 a) recursive objects (compound objects that, directly or indirectly,18 contain a reference to themselves) may cause a recursive loop19 b) because deep copy copies *everything* it may copy too much, e.g.20 administrative data structures that should be shared even between21 copies22Python's deep copy operation avoids these problems by:23 a) keeping a table of objects already copied during the current24 copying pass25 b) letting user-defined classes override the copying operation or the26 set of components copied27This version does not copy types like module, class, function, method,28nor stack trace, stack frame, nor file, socket, window, nor array, nor29any similar types.30Classes can use the same interfaces to control copying that they use31to control pickling: they can define methods called __getinitargs__(),32__getstate__() and __setstate__(). See the documentation for module33"pickle" for information on these methods.34"""35import types36import weakref37from copy_reg import dispatch_table38class Error(Exception):39 pass40error = Error # backward compatibility41try:42 from org.python.core import PyStringMap43except ImportError:44 PyStringMap = None45__all__ = ["Error", "copy", "deepcopy"]46def copy(x):47 """Shallow copy operation on arbitrary Python objects.48 See the module's __doc__ string for more info.49 """50 cls = type(x)51 copier = _copy_dispatch.get(cls)52 if copier:53 return copier(x)54 copier = getattr(cls, "__copy__", None)55 if copier:56 return copier(x)57 reductor = dispatch_table.get(cls)58 if reductor:59 rv = reductor(x)60 else:61 reductor = getattr(x, "__reduce_ex__", None)62 if reductor:63 rv = reductor(2)64 else:65 reductor = getattr(x, "__reduce__", None)66 if reductor:67 rv = reductor()68 else:69 raise Error("un(shallow)copyable object of type %s" % cls)70 return _reconstruct(x, rv, 0)71_copy_dispatch = d = {}72def _copy_immutable(x):73 return x74for t in (type(None), int, long, float, bool, str, tuple,75 frozenset, type, xrange, types.ClassType,76 types.BuiltinFunctionType, type(Ellipsis),77 types.FunctionType, weakref.ref):78 d[t] = _copy_immutable79for name in ("ComplexType", "UnicodeType", "CodeType"):80 t = getattr(types, name, None)81 if t is not None:82 d[t] = _copy_immutable83def _copy_with_constructor(x):84 return type(x)(x)85for t in (list, dict, set):86 d[t] = _copy_with_constructor87def _copy_with_copy_method(x):88 return x.copy()89if PyStringMap is not None:90 d[PyStringMap] = _copy_with_copy_method91def _copy_inst(x):92 if hasattr(x, '__copy__'):93 return x.__copy__()94 if hasattr(x, '__getinitargs__'):95 args = x.__getinitargs__()96 y = x.__class__(*args)97 else:98 y = _EmptyClass()99 y.__class__ = x.__class__100 if hasattr(x, '__getstate__'):101 state = x.__getstate__()102 else:103 state = x.__dict__104 if hasattr(y, '__setstate__'):105 y.__setstate__(state)106 else:107 y.__dict__.update(state)108 return y109d[types.InstanceType] = _copy_inst110del d111def deepcopy(x, memo=None, _nil=[]):112 """Deep copy operation on arbitrary Python objects.113 See the module's __doc__ string for more info.114 """115 if memo is None:116 memo = {}117 d = id(x)118 y = memo.get(d, _nil)119 if y is not _nil:120 return y121 cls = type(x)122 copier = _deepcopy_dispatch.get(cls)123 if copier:124 y = copier(x, memo)125 else:126 try:127 issc = issubclass(cls, type)128 except TypeError: # cls is not a class (old Boost; see SF #502085)129 issc = 0130 if issc:131 y = _deepcopy_atomic(x, memo)132 else:133 copier = getattr(x, "__deepcopy__", None)134 if copier:135 y = copier(memo)136 else:137 reductor = dispatch_table.get(cls)138 if reductor:139 rv = reductor(x)140 else:141 reductor = getattr(x, "__reduce_ex__", None)142 if reductor:143 rv = reductor(2)144 else:145 reductor = getattr(x, "__reduce__", None)146 if reductor:147 rv = reductor()148 else:149 raise Error(150 "un(deep)copyable object of type %s" % cls)151 y = _reconstruct(x, rv, 1, memo)152 memo[d] = y153 _keep_alive(x, memo) # Make sure x lives at least as long as d154 return y155_deepcopy_dispatch = d = {}156def _deepcopy_atomic(x, memo):157 return x158d[type(None)] = _deepcopy_atomic159d[type(Ellipsis)] = _deepcopy_atomic160d[int] = _deepcopy_atomic161d[long] = _deepcopy_atomic162d[float] = _deepcopy_atomic163d[bool] = _deepcopy_atomic164try:165 d[complex] = _deepcopy_atomic166except NameError:167 pass168d[str] = _deepcopy_atomic169try:170 d[unicode] = _deepcopy_atomic171except NameError:172 pass173try:174 d[types.CodeType] = _deepcopy_atomic175except AttributeError:176 pass177d[type] = _deepcopy_atomic178d[xrange] = _deepcopy_atomic179d[types.ClassType] = _deepcopy_atomic180d[types.BuiltinFunctionType] = _deepcopy_atomic181d[types.FunctionType] = _deepcopy_atomic182d[weakref.ref] = _deepcopy_atomic183def _deepcopy_list(x, memo):184 y = []185 memo[id(x)] = y186 for a in x:187 y.append(deepcopy(a, memo))188 return y189d[list] = _deepcopy_list190def _deepcopy_tuple(x, memo):191 y = []192 for a in x:193 y.append(deepcopy(a, memo))194 d = id(x)195 try:196 return memo[d]197 except KeyError:198 pass199 for i in range(len(x)):200 if x[i] is not y[i]:201 y = tuple(y)202 break203 else:204 y = x205 memo[d] = y206 return y207d[tuple] = _deepcopy_tuple208def _deepcopy_dict(x, memo):209 y = {}210 memo[id(x)] = y211 for key, value in x.iteritems():212 y[deepcopy(key, memo)] = deepcopy(value, memo)213 return y214d[dict] = _deepcopy_dict215if PyStringMap is not None:216 d[PyStringMap] = _deepcopy_dict217def _deepcopy_method(x, memo): # Copy instance methods218 return type(x)(x.im_func, deepcopy(x.im_self, memo), x.im_class)219_deepcopy_dispatch[types.MethodType] = _deepcopy_method220def _keep_alive(x, memo):221 """Keeps a reference to the object x in the memo.222 Because we remember objects by their id, we have223 to assure that possibly temporary objects are kept224 alive by referencing them.225 We store a reference at the id of the memo, which should226 normally not be used unless someone tries to deepcopy227 the memo itself...228 """229 try:230 memo[id(memo)].append(x)231 except KeyError:232 # aha, this is the first one :-)233 memo[id(memo)]=[x]234def _deepcopy_inst(x, memo):235 if hasattr(x, '__deepcopy__'):236 return x.__deepcopy__(memo)237 if hasattr(x, '__getinitargs__'):238 args = x.__getinitargs__()239 args = deepcopy(args, memo)240 y = x.__class__(*args)241 else:242 y = _EmptyClass()243 y.__class__ = x.__class__244 memo[id(x)] = y245 if hasattr(x, '__getstate__'):246 state = x.__getstate__()247 else:248 state = x.__dict__249 state = deepcopy(state, memo)250 if hasattr(y, '__setstate__'):251 y.__setstate__(state)252 else:253 y.__dict__.update(state)254 return y255d[types.InstanceType] = _deepcopy_inst256def _reconstruct(x, info, deep, memo=None):257 if isinstance(info, str):258 return x259 assert isinstance(info, tuple)260 if memo is None:261 memo = {}262 n = len(info)263 assert n in (2, 3, 4, 5)264 callable, args = info[:2]265 if n > 2:266 state = info[2]267 else:268 state = {}269 if n > 3:270 listiter = info[3]271 else:272 listiter = None273 if n > 4:274 dictiter = info[4]275 else:276 dictiter = None277 if deep:278 args = deepcopy(args, memo)279 y = callable(*args)280 memo[id(x)] = y281 if state:282 if deep:283 state = deepcopy(state, memo)284 if hasattr(y, '__setstate__'):285 y.__setstate__(state)286 else:287 if isinstance(state, tuple) and len(state) == 2:288 state, slotstate = state289 else:290 slotstate = None291 if state is not None:292 y.__dict__.update(state)293 if slotstate is not None:294 for key, value in slotstate.iteritems():295 setattr(y, key, value)296 if listiter is not None:297 for item in listiter:298 if deep:299 item = deepcopy(item, memo)300 y.append(item)301 if dictiter is not None:302 for key, value in dictiter:303 if deep:304 key = deepcopy(key, memo)305 value = deepcopy(value, memo)306 y[key] = value307 return y308del d309del types310# Helper for instance creation without calling __init__311class _EmptyClass:312 pass313def _test():314 l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'],315 {'abc': 'ABC'}, (), [], {}]316 l1 = copy(l)317 print l1==l318 l1 = map(copy, l)319 print l1==l320 l1 = deepcopy(l)321 print l1==l322 class C:323 def __init__(self, arg=None):324 self.a = 1325 self.arg = arg326 if __name__ == '__main__':327 import sys328 file = sys.argv[0]329 else:330 file = __file__331 self.fp = open(file)332 self.fp.close()333 def __getstate__(self):334 return {'a': self.a, 'arg': self.arg}335 def __setstate__(self, state):336 for key, value in state.iteritems():337 setattr(self, key, value)338 def __deepcopy__(self, memo=None):339 new = self.__class__(deepcopy(self.arg, memo))340 new.a = self.a341 return new342 c = C('argument sketch')343 l.append(c)344 l2 = copy(l)345 print l == l2346 print l347 print l2348 l2 = deepcopy(l)349 print l == l2350 print l351 print l2352 l.append({l[1]: l, 'xyz': l[2]})353 l3 = copy(l)354 import repr355 print map(repr.repr, l)356 print map(repr.repr, l1)357 print map(repr.repr, l2)358 print map(repr.repr, l3)359 l3 = deepcopy(l)360 import repr361 print map(repr.repr, l)362 print map(repr.repr, l1)363 print map(repr.repr, l2)364 print map(repr.repr, l3)365 class odict(dict):366 def __init__(self, d = {}):367 self.a = 99368 dict.__init__(self, d)369 def __setitem__(self, k, i):370 dict.__setitem__(self, k, i)371 self.a372 o = odict({"A" : "B"})373 x = deepcopy(o)374 print(o, x)375if __name__ == '__main__':...

Full Screen

Full Screen

oagis.js

Source:oagis.js Github

copy

Full Screen

...34var PartyType = exports.PartyType = {35 PartyIDs: {ID: []},36 AccountID: null,37 Name: null,38 Location: LocationType.deepCopy(),39 Contact: ContactType.deepCopy()40}41var CustomerPartyType = exports.CustomerPartyType = {42 PartyIDs: {ID: []},43 AccountID: null,44 Name: undefined,45 Location: LocationType.deepCopy(),46 Contact: ContactType.deepCopy(),47 CustomerAccountID: null48}49var SupplierPartyType = exports.SupplierPartyType = {50 PartyIDs: {ID: []},51 AccountID: null,52 Name: undefined,53 Location: LocationType.deepCopy(),54 Contact: ContactType.deepCopy(),55}56var HeaderType = exports.HeaderType = {57 DocumentID: {ID: null},58 DocumentReference: {DocumentID: {ID: null}},59 LastModificationDateTime: null,60 DocumentDateTime: null61}62var RequestHeaderType = exports.RequestHeaderType = HeaderType.deepCopy().extend({63 CustomerParty: CustomerPartyType.deepCopy(),64 SupplierParty: SupplierPartyType.deepCopy(),65 Description: [],66 Note: [],67 DocumentDateTime: null,68})69var RFQLineType = exports.RFQLineType = {70 LineNumber: null,71 DocumentReference: {72 SalesOrderReference: {LineNumber: null}73 },74 Description: null,75 Quantity: null,76 Quantity_unitCode: null77}78var RFQ = exports.RFQ = {79 RFQHeader: RequestHeaderType.deepCopy(),80 RFQLine: []81}82var SalesOrder = exports.SalesOrder = {83 SalesOrderHeader: RequestHeaderType.deepCopy(),84 SalesOrderLine: []85}86var QuoteLineType = exports.QuoteLineType = {87 LineNumber: null,88 DocumentReference: {89 SalesOrderReference: {LineNumber: null}90 },91 Description: null,92 Quantity: null,93 Quantity_unitCode: null,94 UnitPrice: {95 Amount: null,96 Amount_currencyID: null,97 PerQuantity: null,98 PerQuantity_unitCode: null99 },100 ExtendedAmount: null,101 ExtendedAmount_currencyID: null,102 TotalAmount: null,103 TotalAmount_currencyID: null104}105var Quote = exports.Quote = {106 QuoteHeader: RequestHeaderType.deepCopy().extend({107 DocumentReference: {108 SalesOrderReference: {DocumentID: {ID: null}}109 },110 RFQReference: {DocumentID: {ID: null}}111 }),112 QuoteLine: []113}114var PurchaseOrder = exports.PurchaseOrder = {115 PurchaseOrderHeader: RequestHeaderType.deepCopy(),116 PurchaseOrderLine: []117}118exports.ProcessRFQ = {119 name: "ProcessRFQ",120 ApplicationArea: {Sender: null, Receiver: null},121 DataArea: {122 RFQ: RFQ.deepCopy(),123 Process: null124 }125}126exports.ProcessQuote = {127 name: "ProcessQuote",128 ApplicationArea: {Sender: null, Receiver: null},129 DataArea: {130 Quote: Quote.deepCopy(),131 Process: null132 }133}134exports.ProcessSalesOrder = BOD.deepCopy().extend({135 name: "ProcessSalesOrder",136 DataArea: {137 Process: null,138 SalesOrder: SalesOrder.deepCopy()139 }140})141exports.SyncSalesOrder = BOD.deepCopy().extend({142 name: "SyncSalesOrder",143 DataArea: {144 Sync: null,145 SalesOrder: SalesOrder.deepCopy()146 }147})148exports.ProcessPurchaseOrder = BOD.deepCopy().extend({149 name: "ProcessPurchaseOrder",150 DataArea: {151 Process: null,152 PurchaseOrder: PurchaseOrder.deepCopy()153 }...

Full Screen

Full Screen

deepcopy_vx.x.x.js

Source:deepcopy_vx.x.x.js Github

copy

Full Screen

1// flow-typed signature: 55fcd3edf9374214993f2d6b8478b1302// flow-typed version: <<STUB>>/deepcopy_v^0.6.3/flow_v0.68.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'deepcopy'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'deepcopy' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'deepcopy/build/deepcopy' {23 declare module.exports: any;24}25declare module 'deepcopy/build/deepcopy.min' {26 declare module.exports: any;27}28declare module 'deepcopy/lib/copy' {29 declare module.exports: any;30}31declare module 'deepcopy/lib/index' {32 declare module.exports: any;33}34declare module 'deepcopy/lib/polyfill' {35 declare module.exports: any;36}37declare module 'deepcopy/src/copy' {38 declare module.exports: any;39}40declare module 'deepcopy/src/index' {41 declare module.exports: any;42}43declare module 'deepcopy/src/polyfill' {44 declare module.exports: any;45}46// Filename aliases47declare module 'deepcopy/build/deepcopy.js' {48 declare module.exports: $Exports<'deepcopy/build/deepcopy'>;49}50declare module 'deepcopy/build/deepcopy.min.js' {51 declare module.exports: $Exports<'deepcopy/build/deepcopy.min'>;52}53declare module 'deepcopy/index' {54 declare module.exports: $Exports<'deepcopy'>;55}56declare module 'deepcopy/index.js' {57 declare module.exports: $Exports<'deepcopy'>;58}59declare module 'deepcopy/lib/copy.js' {60 declare module.exports: $Exports<'deepcopy/lib/copy'>;61}62declare module 'deepcopy/lib/index.js' {63 declare module.exports: $Exports<'deepcopy/lib/index'>;64}65declare module 'deepcopy/lib/polyfill.js' {66 declare module.exports: $Exports<'deepcopy/lib/polyfill'>;67}68declare module 'deepcopy/src/copy.js' {69 declare module.exports: $Exports<'deepcopy/src/copy'>;70}71declare module 'deepcopy/src/index.js' {72 declare module.exports: $Exports<'deepcopy/src/index'>;73}74declare module 'deepcopy/src/polyfill.js' {75 declare module.exports: $Exports<'deepcopy/src/polyfill'>;...

Full Screen

Full Screen

deepCopy-test.js

Source:deepCopy-test.js Github

copy

Full Screen

2import {expect} from 'chai';3import deepCopy from '../src/deepCopy';4suite('deepCopy', () => {5 test('primitives', () => {6 expect(deepCopy(null)).to.equal(null);7 expect(deepCopy(12)).to.equal(12);8 expect(deepCopy('foo')).to.equal('foo');9 expect(deepCopy(false)).to.equal(false);10 });11 test('dates', () => {12 let d = new Date();13 let copy = deepCopy(d);14 expect(d).to.not.equal(copy);15 expect(d.getTime()).to.equal(copy.getTime());16 });17 test('arrays', () => {18 let arr = [1,3,5];19 let copy = deepCopy(arr);20 expect(copy).to.deep.equal([1,3,5]);21 expect(copy).to.not.equal(arr);22 arr = [1,2,[3,4,5]];23 copy = deepCopy(arr);24 expect(copy).to.deep.equal([1,2,[3,4,5]]);25 expect(copy).to.not.equal(arr);26 expect(copy[2]).to.not.equal(arr[2]);27 let a = ['a', 'b'];28 let b = [[a]];29 a[2] = b;30 expect(() => deepCopy(a)).to.throw();31 });32 test('objects', () => {33 let obj = {a: 1, b: 2};34 let copy = deepCopy(obj);35 expect(copy).to.deep.equal(obj);36 expect(copy).to.not.equal(obj);37 obj = {a: 1, b: {c: 5}};38 copy = deepCopy(obj);39 expect(copy).to.deep.equal(obj);40 expect(copy).to.not.equal(obj);41 expect(copy.b).to.not.equal(obj.b);42 expect(copy.b).to.not.equal(obj.b);43 obj = {a: 1, b: {c: {d: {e: 7}}}};44 copy = deepCopy(obj);45 expect(copy).to.deep.equal(obj);46 expect(copy).to.not.equal(obj);47 expect(copy.b).to.not.equal(obj.b);48 expect(copy.b.c).to.not.equal(obj.b.c);49 expect(copy.b.c.d).to.not.equal(obj.b.c.d);50 let a = {a: 1, b: 2};51 let b = {parent: a};52 a.child = b;53 expect(() => deepCopy(a)).to.throw();54 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('./wptools.js');2var obj1 = { a: 1, b: 2, c: 3 };3var obj2 = wptools.deepCopy(obj1);4obj2.a = 4;5var wptools = {};6wptools.deepCopy = function(obj) {7 var newObj = (obj instanceof Array) ? [] : {};8 for (var i in obj) {9 if (obj[i] && typeof obj[i] == "object") {10 newObj[i] = wptools.deepCopy(obj[i]);11 } else {12 newObj[i] = obj[i];13 }14 }15 return newObj;16};17module.exports = wptools;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var obj = {a:1, b:2, c:3};3var obj2 = wptools.deepCopy(obj);4obj2.a = 4;5Your name to display (optional):6Your name to display (optional):7var obj = {a:1, b:2, c:3};8var obj2 = Object.assign({}, obj);9obj2.a = 4;10Your name to display (optional):

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wp-toolkit');2var obj = {3 c: {4 }5};6var obj2 = wptoolkit.deepCopy(obj);7console.log(obj2);8var objectAssign = require('object-assign');9var obj = {10 c: {11 }12};13var obj2 = objectAssign({}, obj);14console.log(obj2);15var _ = require('lodash');16var obj = {17 c: {18 }19};20var obj2 = _.cloneDeep(obj);21console.log(obj2);22var _ = require('lodash');23var obj = {24 c: {25 }26};27var obj2 = _.cloneDeep(obj);28console.log(obj2);29var _ = require('lodash');30var obj = {31 c: {32 }33};34var obj2 = _.cloneDeep(obj);35console.log(obj2);36var _ = require('lodash');37var obj = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var obj = {a:1,b:2};3var obj2 = wptools.deepCopy(obj);4obj2.a = 3;5var wptools = require('wptools');6var obj = {a:1,b:2};7var obj2 = wptools.deepCopy(obj);8obj2.a = 3;9var wptools = require('wptools');10var obj = {a:1,b:2};11var obj2 = wptools.deepCopy(obj);12obj2.a = 3;13var wptools = require('wptools');14var obj = {a:1,b:2};15var obj2 = wptools.deepCopy(obj);16obj2.a = 3;17var wptools = require('wptools');18var obj = {a:1,b:2};19var obj2 = wptools.deepCopy(obj);20obj2.a = 3;21var wptools = require('wptools');22var obj = {a:1,b:2};23var obj2 = wptools.deepCopy(obj);24obj2.a = 3;25var wptools = require('wptools');26var obj = {a:1,b:2};27var obj2 = wptools.deepCopy(obj);28obj2.a = 3;29var wptools = require('wptools');30var obj = {a:1,b:2};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var util = require('util');3var deepCopy = wpt.deepCopy;4var obj = {5 c: {6 }7};8var copy = deepCopy(obj);9console.log(util.inspect(copy));10wpt.deepCopy(object)11var wpt = require('wpt');12var util = require('util');13var deepCopy = wpt.deepCopy;14var obj = {15 c: {16 }17};18var copy = deepCopy(obj);19console.log(util.inspect(copy));20wpt.deepCopy(object)21wpt.extend(target, source)22wpt.isObject(object)23wpt.isFunction(object)24wpt.isString(object)25wpt.isNumber(object)26wpt.isBoolean(object)27wpt.isUndefined(object)28wpt.isNull(object)29wpt.isArray(object)30wpt.isDate(object)31wpt.isRegExp(object)32wpt.isError(object)33wpt.isArguments(object)34wpt.isEmpty(object)35wpt.isEqual(object1, object2)36wpt.isEqualWith(object1, object2, customizer)37wpt.isMatch(object, source)38wpt.isMatchWith(object, source, customizer)39wpt.isElement(object)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wp-toolkit');2var obj = {a:1, b:2};3var obj2 = wptoolkit.deepCopy(obj);4console.log(obj2);5var wptoolkit = require('wp-toolkit');6var obj = {a:1, b:2};7var obj2 = wptoolkit.deepCopy(obj);8console.log(obj2);9var wptoolkit = require('wp-toolkit');10var obj = {a:1, b:2};11var obj2 = wptoolkit.deepCopy(obj);12console.log(obj2);13var wptoolkit = require('wp-toolkit');14var obj = {a:1, b:2};15var obj2 = wptoolkit.deepCopy(obj);16console.log(obj2);17var wptoolkit = require('wp-toolkit');18var obj = {a:1, b:2};19var obj2 = wptoolkit.deepCopy(obj);20console.log(obj2);21var wptoolkit = require('wp-toolkit');22var obj = {a:1, b:2};23var obj2 = wptoolkit.deepCopy(obj);24console.log(obj2);25var wptoolkit = require('wp-toolkit');26var obj = {a:1, b:2};27var obj2 = wptoolkit.deepCopy(obj);28console.log(obj2);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5wpt.runTest(testUrl, options, function(err, data) {6 if (err) return console.log(err);7 var testId = data.data.testId;8 var testResults = data.data;9 console.log(testResults);10 wpt.getTestResults(testId, function(err, data) {11 if (err) return console.log(err);12 var testResults = data.data;13 console.log(testResults);14 });15});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var obj = {a:1, b:2, c:3};3var obj2 = wpt.utils.deepCopy(obj);4obj2.a = 100;5console.log(obj);6console.log(obj2);7var wpt = require('wpt');8var obj = {a:1, b:2, c:3};9var obj2 = wpt.utils.deepCopy(obj);10obj2.a = 100;11console.log(obj);12console.log(obj2);13var wpt = require('wpt');14var obj = {a:1, b:2, c:3};15var obj2 = wpt.utils.deepCopy(obj);16obj2.a = 100;17console.log(obj);18console.log(obj2);19var wpt = require('wpt');20var obj = {a:1, b:2, c:3};21var obj2 = wpt.utils.deepCopy(obj);22obj2.a = 100;23console.log(obj);24console.log(obj2);25var wpt = require('wpt');26var obj = {a:1, b:2, c:3};27var obj2 = wpt.utils.deepCopy(obj);28obj2.a = 100;29console.log(obj);30console.log(obj2);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var deepCopy = wpt.deepCopy;3var obj = {a: 1, b: 2};4var obj2 = deepCopy(obj);5obj2.a = 3;6var wpt = require('webpagetest');7var deepCopy = wpt.deepCopy;8var obj = {a: 1, b: 2};9var obj2 = deepCopy(obj);10obj2.a = 3;11var wpt = require('webpagetest');12var deepCopy = wpt.deepCopy;13var obj = {a: 1, b: 2};14var obj2 = deepCopy(obj);15obj2.a = 3;16var wpt = require('webpagetest');17var deepCopy = wpt.deepCopy;18var obj = {a: 1, b: 2};19var obj2 = deepCopy(obj);20obj2.a = 3;21var wpt = require('webpagetest');22var deepCopy = wpt.deepCopy;23var obj = {a: 1, b: 2};24var obj2 = deepCopy(obj);25obj2.a = 3;26var wpt = require('webpagetest');27var deepCopy = wpt.deepCopy;28var obj = {a: 1, b: 2};29var obj2 = deepCopy(obj);30obj2.a = 3;

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful