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

Method test_frozen

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

Source from the content-addressed store, hash-verified

584 getattr(bx, "(3, 4)")
585
586 def test_frozen(self):
587 bx = Box(extended_test_dict, frozen_box=True)
588
589 assert isinstance(bx.alist, tuple)
590 assert bx.alist[0] == {"a": 1}
591 with pytest.raises(BoxError):
592 bx.new = 3
593
594 with pytest.raises(BoxError):
595 bx["new"] = 3
596
597 with pytest.raises(BoxError):
598 del bx["not"]
599
600 with pytest.raises(BoxError):
601 delattr(bx, "key1")
602
603 with pytest.raises(TypeError):
604 hash(bx)
605
606 with pytest.raises(BoxError):
607 bx.clear()
608
609 with pytest.raises(BoxError):
610 bx.pop("alist")
611
612 with pytest.raises(BoxError):
613 bx.popitem()
614
615 with pytest.raises(BoxError):
616 bx.popitem()
617
618 with pytest.raises(BoxError):
619 bx.update({"another_list": []})
620
621 bx2 = Box(test_dict)
622 with pytest.raises(TypeError):
623 hash(bx2)
624
625 bx3 = Box(test_dict, frozen_box=True)
626
627 assert hash(bx3)
628
629 def test_frozen_box_with_lists_is_serializable(self):
630 # 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