MCPcopy Create free account
hub / github.com/cdgriffith/Box / test_frozen

Method test_frozen

test/test_box.py:537–578  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

535 getattr(bx, "(3, 4)")
536
537 def test_frozen(self):
538 bx = Box(extended_test_dict, frozen_box=True)
539
540 assert isinstance(bx.alist, tuple)
541 assert bx.alist[0] == {"a": 1}
542 with pytest.raises(BoxError):
543 bx.new = 3
544
545 with pytest.raises(BoxError):
546 bx["new"] = 3
547
548 with pytest.raises(BoxError):
549 del bx["not"]
550
551 with pytest.raises(BoxError):
552 delattr(bx, "key1")
553
554 with pytest.raises(TypeError):
555 hash(bx)
556
557 with pytest.raises(BoxError):
558 bx.clear()
559
560 with pytest.raises(BoxError):
561 bx.pop("alist")
562
563 with pytest.raises(BoxError):
564 bx.popitem()
565
566 with pytest.raises(BoxError):
567 bx.popitem()
568
569 with pytest.raises(BoxError):
570 bx.update({"another_list": []})
571
572 bx2 = Box(test_dict)
573 with pytest.raises(TypeError):
574 hash(bx2)
575
576 bx3 = Box(test_dict, frozen_box=True)
577
578 assert hash(bx3)
579
580 def test_frozen_box_with_lists_is_serializable(self):
581 # frozen_box stores lists as tuples of Boxes; to_dict must convert the

Callers

nothing calls this directly

Calls 5

clearMethod · 0.95
popMethod · 0.95
popitemMethod · 0.95
updateMethod · 0.95
BoxClass · 0.90

Tested by

no test coverage detected