Skip to content

Commit dede000

Browse files
authored
Merge pull request #401 from tangkong/tst_hist_timeouts
TST: fix hist file test timeouts
2 parents 8097f72 + 872e4bb commit dede000

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
401 tst_hist_timeouts
2+
#####################
3+
4+
API Changes
5+
-----------
6+
- N/A
7+
8+
Features
9+
--------
10+
- N/A
11+
12+
Bugfixes
13+
--------
14+
- N/A
15+
16+
Maintenance
17+
-----------
18+
- Separate test_hist_file_arg into three separate test cases to hopefully alleviate test suite timeout issues
19+
20+
Contributors
21+
------------
22+
- tangkong

hutch_python/tests/test_cli.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def test_create_arg():
7575
if test_dir.exists():
7676
shutil.rmtree(test_dir)
7777

78+
# Needs manual confirmation if we run with capture output on...
7879
with cli_args(['hutch_python', '--create', hutch]):
7980
with restore_logging():
8081
main()
@@ -96,11 +97,9 @@ def run_hpy_and_exit(*args: str) -> subprocess.CompletedProcess:
9697

9798

9899
@pytest.mark.timeout(30)
99-
def test_hist_file_arg(monkeypatch):
100+
def test_hist_file_arg():
100101
logger.debug("test_hist_file_arg")
101102
test_hist_file = (CFG_PATH.parent / "history.sqlite").resolve()
102-
bad_hist_file = (CFG_PATH.parent / "aesefiudh" / "history.sqlite").resolve()
103-
memory_hist_filename = ":memory:"
104103

105104
# Test that the sqlite file gets made
106105
# First, need to remove the file if it already exists
@@ -113,17 +112,27 @@ def test_hist_file_arg(monkeypatch):
113112
assert test_hist_file.exists()
114113
# Remove the file for future tests
115114
test_hist_file.unlink()
116-
# With the bad hist file we should still run ok with just a warning
117-
run_hpy_and_exit("--hist-file", str(bad_hist_file))
118115
assert not test_hist_file.exists()
119-
# Same with the in-memory choice
120-
run_hpy_and_exit("--hist-file", memory_hist_filename)
116+
117+
118+
@pytest.mark.timeout(30)
119+
@pytest.mark.parametrize("filepath,", (
120+
(CFG_PATH.parent / "aesefiudh" / "history.sqlite").resolve(),
121+
":memory:",
122+
))
123+
def test_no_hist_file(filepath):
124+
# With the bad hist file or memory we should still run ok with just a warning
125+
test_hist_file = (CFG_PATH.parent / "history.sqlite").resolve()
126+
run_hpy_and_exit("--hist-file", str(filepath))
121127
assert not test_hist_file.exists()
122128

129+
130+
@pytest.mark.timeout(30)
131+
def test_template_file(monkeypatch):
123132
# Exercise the template + check default usage
124133
# We can't actually write to the default default in a test context
125134
# But we can check what the config would be
126-
new_default = str(test_hist_file.parent / "${USER}-history.sqlite")
135+
new_default = str(CFG_PATH.parent / "${USER}-history.sqlite")
127136
new_default_filled = Template(new_default).substitute({"USER": os.environ["USER"]})
128137
monkeypatch.setattr(
129138
hutch_python.cli,

0 commit comments

Comments
 (0)