def test_to_script(index): """Test writing DataFrameSchema to a script.""" schema_to_write = _create_schema(index) script = io.to_script(schema_to_write) local_dict = {} # pylint: disable=exec-used exec(script, globals(), local_dict) schema = local_dict["schema"] # executing script should result in a variable `schema` assert schema == schema_to_write
def test_to_script(index): """Test writing DataFrameSchema to a script.""" schema_to_write = _create_schema(index) for script in [io.to_script(schema_to_write), schema_to_write.to_script()]: local_dict = {} # pylint: disable=exec-used exec(script, globals(), local_dict) schema = local_dict["schema"] # executing script should result in a variable `schema` assert schema == schema_to_write with tempfile.NamedTemporaryFile("w+") as f: schema_to_write.to_script(Path(f.name)) # pylint: disable=exec-used exec(f.read(), globals(), local_dict) schema = local_dict["schema"] assert schema == schema_to_write