def test_create_and_register(self): lib = PushTypeLibrary(register_core=False) lib.create_and_register("seq", (list, tuple)) assert set(lib.keys()) == {"seq", "exec", "code"} new_type = lib["seq"] assert new_type.is_instance((1, 2, 3)) assert new_type.is_instance([1, 2, 3])
def test_create_and_register(self): lib = PushTypeLibrary(register_core=False) lib.create_and_register("seq", (list, tuple)) assert set(lib.keys()) == {"seq", "exec", "code"} new_type = lib["seq"] assert new_type.is_instance((1, 2, 3)) assert new_type.is_instance([1, 2, 3])
def test_register_reserved(self): lib = PushTypeLibrary(register_core=False) with pytest.raises(ValueError): lib.create_and_register("stdout", (list, ))
def test_register_duplicates(self): lib = PushTypeLibrary(register_core=False) lib.create_and_register("char", (int, )) lib.register(PushChar) assert set(lib.keys()) == {"char", "exec", "code"} assert lib["char"] == PushChar
def test_register_reserved(self): lib = PushTypeLibrary(register_core=False) with pytest.raises(ValueError): lib.create_and_register("exec", (list, ))
def test_register_duplicates(self): lib = PushTypeLibrary(register_core=False) lib.create_and_register("char", (int, )) lib.register(PushChar) assert set(lib.keys()) == {"char", "exec", "code"} assert lib["char"] == PushChar