def test_make_usable_as_dagster_type_called_twice(): class AType: pass ADagsterType = PythonObjectDagsterType(AType, name="ADagsterType",) BDagsterType = PythonObjectDagsterType(AType, name="BDagsterType",) make_python_type_usable_as_dagster_type(AType, ADagsterType) make_python_type_usable_as_dagster_type(AType, ADagsterType) # should not raise an error with pytest.raises(DagsterInvalidDefinitionError): make_python_type_usable_as_dagster_type(AType, BDagsterType)
def test_python_object_union_type(): ntype = PythonObjectDagsterType(python_type=(int, float)) assert ntype.unique_name == "Union[int, float]" assert_success(ntype, 1) assert_success(ntype, 1.5) assert_failure(ntype, "a")
def test_tuple_union_typing_type(): UnionType = PythonObjectDagsterType(python_type=(str, int, float)) assert UnionType.typing_type == typing.Union[str, int, float]