def test_register_classes_override():
    """Test that register_classes overrides existing entries in the class index."""
    class MyProcessSpec(ProcessSpec):
        pass

    normal = GEMDJson()
    custom = GEMDJson()
    custom.register_classes({MyProcessSpec.typ: MyProcessSpec})

    obj = ProcessSpec(name="foo")
    assert not isinstance(normal.copy(obj), MyProcessSpec),\
        "Class registration bled across GEMDJson() objects"

    assert isinstance(custom.copy(obj), ProcessSpec),\
        "Custom GEMDJson didn't deserialize as MyProcessSpec"
def test_register_argument_validation():
    """Test that register_classes argument is type checked."""
    orig = GEMDJson()

    with pytest.raises(ValueError):
        orig.register_classes("foo")

    with pytest.raises(ValueError):
        orig.register_classes({"foo": orig})

    with pytest.raises(ValueError):
        orig.register_classes({ProcessSpec: ProcessSpec})