From ae67dfa5a9dd22226d260dd47a5f7249bac43b94 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Wed, 19 Oct 2022 18:16:45 +0300 Subject: [PATCH] tests: Test filenames with spaces in them Add two tests that check if Dangerzone properly handles input and output filenames with spaces in them. Previously this was not straight-forward because we didn't tokenize arguments, which lead to Click splitting filenames with spaces in two. --- tests/test_cli.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 7ce3f85..2f7e91a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -16,7 +16,6 @@ from dangerzone.cli import cli_main, display_banner from . import TestBase, for_each_doc -# TODO --output-filename with spaces # TODO explore any symlink edge cases # TODO simulate ctrl-c, ctrl-d, SIGINT/SIGKILL/SIGTERM... (man 7 signal), etc? # TODO validate output PDFs https://github.com/pdfminer/pdfminer.six @@ -165,6 +164,13 @@ class TestCliConversion(TestCliBasic): ) result.assert_success() + def test_output_filename_spaces(self): + temp_dir = tempfile.mkdtemp(prefix="dangerzone-") + result = self.run_cli( + [self.sample_doc, "--output-filename", f"{temp_dir}/safe space.pdf"] + ) + result.assert_success() + def test_output_filename_new_dir(self): result = self.run_cli( [self.sample_doc, "--output-filename", "fake-directory/my-output.pdf"] @@ -184,6 +190,7 @@ class TestCliConversion(TestCliBasic): [ "“Curly_Quotes”.pdf", # issue 144 "Оригинал.pdf", + "spaces test.pdf", ], ) def test_filenames(self, filename):