Skip to content

Commit 5a5731d

Browse files
aabiddandamergify[bot]
authored andcommitted
feat: error for more than one file with compression to stdout
1 parent 73fe8a0 commit 5a5731d

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
--------------------
2-
[0.2.1] - 2021-01-26
2+
[0.2.2] - 2022-02-22
3+
--------------------
4+
5+
- Support compressing to stdout (aabiddanda, #53, #64)
6+
7+
--------------------
8+
[0.2.1] - 2022-01-26
39
--------------------
410

511
- Fix for `time_units` in tskit 0.4.0 (benjeffery, #54, #55)

tests/test_cli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,17 @@ def test_compress_stdout_correct(self):
312312
ts = tszip.decompress(str(tmp_file))
313313
self.assertEqual(ts.tables, self.ts.tables)
314314

315+
def test_compress_stdout_multiple(self):
316+
self.assertTrue(self.trees_path.exists())
317+
with mock.patch("tszip.cli.exit", side_effect=TestException) as mocked_exit:
318+
with self.assertRaises(TestException):
319+
self.run_tszip_stdout(
320+
["-c", str(self.trees_path), str(self.trees_path)]
321+
)
322+
mocked_exit.assert_called_once_with(
323+
"Only one file can be compressed on with '-c'"
324+
)
325+
315326

316327
class DecompressSemanticsMixin:
317328
"""

tszip/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ def run_compress(args):
111111
if args.stdout:
112112
args.keep = True
113113
setup_logging(args)
114+
if args.stdout and len(args.files) > 1:
115+
exit("Only one file can be compressed on with '-c'")
114116
for file_arg in args.files:
115117
logger.info(f"Compressing {file_arg}")
116118
try:

0 commit comments

Comments
 (0)