mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
tests: Tokenize CLI arguments
Pass tokenized arguments (i.e., arguments as lists of strings) to CLI invocations, else Click will attempt to tokenize them internally. The problem with leaving tokenization to Click is that it uses `shlex.split()`, which is Unix-oriented, and may miss some cases in Windows.
This commit is contained in:
parent
6b7797639c
commit
51d4fb04c8
1 changed files with 5 additions and 5 deletions
|
@ -150,24 +150,24 @@ class TestCliBasic(TestCli):
|
||||||
|
|
||||||
class TestCliConversion(TestCliBasic):
|
class TestCliConversion(TestCliBasic):
|
||||||
def test_invalid_lang(self):
|
def test_invalid_lang(self):
|
||||||
result = self.run_cli(f"{self.sample_doc} --ocr-lang piglatin")
|
result = self.run_cli([self.sample_doc, "--ocr-lang", "piglatin"])
|
||||||
result.assert_failure()
|
result.assert_failure()
|
||||||
|
|
||||||
@for_each_doc
|
@for_each_doc
|
||||||
def test_formats(self, doc):
|
def test_formats(self, doc):
|
||||||
result = self.run_cli(f'"{doc}"')
|
result = self.run_cli(str(doc))
|
||||||
result.assert_success()
|
result.assert_success()
|
||||||
|
|
||||||
def test_output_filename(self):
|
def test_output_filename(self):
|
||||||
temp_dir = tempfile.mkdtemp(prefix="dangerzone-")
|
temp_dir = tempfile.mkdtemp(prefix="dangerzone-")
|
||||||
result = self.run_cli(
|
result = self.run_cli(
|
||||||
f"{self.sample_doc} --output-filename {temp_dir}/safe.pdf"
|
[self.sample_doc, "--output-filename", f"{temp_dir}/safe.pdf"]
|
||||||
)
|
)
|
||||||
result.assert_success()
|
result.assert_success()
|
||||||
|
|
||||||
def test_output_filename_new_dir(self):
|
def test_output_filename_new_dir(self):
|
||||||
result = self.run_cli(
|
result = self.run_cli(
|
||||||
f"{self.sample_doc} --output-filename fake-directory/my-output.pdf"
|
[self.sample_doc, "--output-filename", "fake-directory/my-output.pdf"]
|
||||||
)
|
)
|
||||||
result.assert_failure()
|
result.assert_failure()
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ class TestCliConversion(TestCliBasic):
|
||||||
result.assert_failure()
|
result.assert_failure()
|
||||||
|
|
||||||
def test_lang_eng(self):
|
def test_lang_eng(self):
|
||||||
result = self.run_cli(f'"{self.sample_doc}" --ocr-lang eng')
|
result = self.run_cli([self.sample_doc, "--ocr-lang", "eng"])
|
||||||
result.assert_success()
|
result.assert_success()
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
Loading…
Reference in a new issue