Skip to content

Commit a128fdc

Browse files
authored
Rebase onto master (#3393)
1 parent 81e457f commit a128fdc

File tree

4 files changed

+23
-47
lines changed

4 files changed

+23
-47
lines changed

parsl/tests/test_bash_apps/test_memoize_ignore_args.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import os
22

3-
import pytest
4-
53
import parsl
64
from parsl.app.app import bash_app
75

@@ -23,24 +21,18 @@ def no_checkpoint_stdout_app_ignore_args(stdout=None):
2321
return "echo X"
2422

2523

26-
def test_memo_stdout():
24+
def test_memo_stdout(tmpd_cwd):
25+
path_x = tmpd_cwd / "test.memo.stdout.x"
2726

2827
# this should run and create a file named after path_x
29-
path_x = "test.memo.stdout.x"
30-
if os.path.exists(path_x):
31-
os.remove(path_x)
32-
33-
no_checkpoint_stdout_app_ignore_args(stdout=path_x).result()
34-
assert os.path.exists(path_x)
35-
36-
# this should be memoized, so not create benc.test.y
37-
path_y = "test.memo.stdout.y"
28+
no_checkpoint_stdout_app_ignore_args(stdout=str(path_x)).result()
29+
assert path_x.exists()
3830

39-
if os.path.exists(path_y):
40-
os.remove(path_y)
31+
# this should be memoized, so should not get created
32+
path_y = tmpd_cwd / "test.memo.stdout.y"
4133

4234
no_checkpoint_stdout_app_ignore_args(stdout=path_y).result()
43-
assert not os.path.exists(path_y)
35+
assert not path_y.exists(), "For memoization, expected NO file written"
4436

4537
# this should also be memoized, so not create an arbitrary name
4638
z_fut = no_checkpoint_stdout_app_ignore_args(stdout=parsl.AUTO_LOGNAME)

parsl/tests/test_bash_apps/test_memoize_ignore_args_regr.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import copy
2-
import os
32
from typing import List
43

54
import pytest
@@ -30,21 +29,17 @@ def no_checkpoint_stdout_app(stdout=None):
3029
return "echo X"
3130

3231

33-
def test_memo_stdout():
34-
32+
def test_memo_stdout(tmpd_cwd):
3533
assert const_list_x == const_list_x_arg
3634

37-
path_x = "test.memo.stdout.x"
38-
if os.path.exists(path_x):
39-
os.remove(path_x)
35+
path_x = tmpd_cwd / "test.memo.stdout.x"
4036

4137
# this should run and create a file named after path_x
42-
no_checkpoint_stdout_app(stdout=path_x).result()
43-
assert os.path.exists(path_x)
38+
no_checkpoint_stdout_app(stdout=str(path_x)).result()
39+
path_x.unlink(missing_ok=False)
4440

45-
os.remove(path_x)
46-
no_checkpoint_stdout_app(stdout=path_x).result()
47-
assert not os.path.exists(path_x)
41+
no_checkpoint_stdout_app(stdout=str(path_x)).result()
42+
assert not path_x.exists(), "For memoization, expected NO file written"
4843

4944
# this should also be memoized, so not create an arbitrary name
5045
z_fut = no_checkpoint_stdout_app(stdout=parsl.AUTO_LOGNAME)

parsl/tests/test_error_handling/test_retries.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import argparse
21
import os
32

43
import pytest
54

6-
import parsl
75
from parsl import bash_app, python_app
86
from parsl.tests.configs.local_threads import fresh_config
97

@@ -68,8 +66,6 @@ def test_fail_nowait(numtasks=10):
6866
assert isinstance(
6967
e, TypeError), "Expected a TypeError, got {}".format(e)
7068

71-
print("Done")
72-
7369

7470
@pytest.mark.local
7571
def test_fail_delayed(numtasks=10):
@@ -94,19 +90,12 @@ def test_fail_delayed(numtasks=10):
9490
assert isinstance(
9591
e, TypeError), "Expected a TypeError, got {}".format(e)
9692

97-
print("Done")
98-
9993

10094
@pytest.mark.local
101-
def test_retry():
95+
def test_retry(tmpd_cwd):
10296
"""Test retries via app that succeeds on the Nth retry.
10397
"""
10498

105-
fname = "retry.out"
106-
try:
107-
os.remove(fname)
108-
except OSError:
109-
pass
110-
fu = succeed_on_retry(fname)
111-
112-
fu.result()
99+
fpath = tmpd_cwd / "retry.out"
100+
sout = str(tmpd_cwd / "stdout")
101+
succeed_on_retry(str(fpath), stdout=sout).result()

parsl/tests/test_staging/test_file.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ def test_files():
2222

2323

2424
@pytest.mark.local
25-
def test_open():
26-
with open('test-open.txt', 'w') as tfile:
27-
tfile.write('Hello')
25+
def test_open(tmpd_cwd):
26+
fpath = tmpd_cwd / 'test-open.txt'
27+
fpath.write_text('Hello')
2828

29-
pfile = File('test-open.txt')
29+
pfile = File(fpath)
3030

31-
with open(str(pfile), 'r') as opfile:
32-
assert (opfile.readlines()[0] == 'Hello')
31+
with open(pfile) as opfile:
32+
assert (opfile.read() == 'Hello')

0 commit comments

Comments
 (0)