Skip to content

Commit

Permalink
Rewrite test to work better on all platforms (#2255)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
  • Loading branch information
2 people authored and fiedlerNr9 committed Jul 25, 2024
1 parent 0729981 commit a526636
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions tests/flytekit/unit/core/test_flyte_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,25 @@ def can_import(module_name) -> bool:


def test_file_type_in_workflow_with_bad_format():
@task
def t1() -> FlyteFile[typing.TypeVar("txt")]:
fname = "/tmp/flytekit_test"
with open(fname, "w") as fh:
fh.write("Hello World\n")
return fname
fd, path = tempfile.mkstemp()
try:

@workflow
def my_wf() -> FlyteFile[typing.TypeVar("txt")]:
f = t1()
return f
@task
def t1() -> FlyteFile[typing.TypeVar("txt")]:
with os.fdopen(fd, "w") as f:
f.write("Hello World\n")
return path

res = my_wf()
with open(res, "r") as fh:
assert fh.read() == "Hello World\n"
@workflow
def my_wf() -> FlyteFile[typing.TypeVar("txt")]:
f = t1()
return f

res = my_wf()
with open(res, "r") as fh:
assert fh.read() == "Hello World\n"
finally:
os.remove(path)


def test_matching_file_types_in_workflow(local_dummy_txt_file):
Expand Down

0 comments on commit a526636

Please sign in to comment.