Skip to content

Commit

Permalink
test: add test case for "apport-gtk --help"
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrung authored and schopin-pro committed Feb 20, 2025
1 parent 7027643 commit ed21b02
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/system/test_ui_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# TODO: Address following pylint complaints
# pylint: disable=invalid-name

import io
import os
import shutil
import subprocess
Expand Down Expand Up @@ -1166,6 +1167,19 @@ def close() -> bool:

self.assertEqual(self.app.ui_start_upload_progress.call_count, 0)

@unittest.mock.patch("sys.stderr", new_callable=io.StringIO)
@unittest.mock.patch("sys.stdout", new_callable=io.StringIO)
def test_help(self, stdout: io.StringIO, stderr: io.StringIO) -> None:
"""Test apport-gtk --help."""
with self.assertRaisesRegex(SystemExit, "^0$"):
apport_gtk.main([str(apport_gtk_path), "--help"])

self.assertEqual(stderr.getvalue(), "")
self.assertRegex(stdout.getvalue(), "^usage: ")
self.assertIn(
"Report the crash from given .apport or .crash file", stdout.getvalue()
)

def test_text_to_markup(self) -> None:
"""Test text_to_markup() with different URLs."""
urls = ["https://example.com", "https://example.com/file-bug-report"]
Expand Down

0 comments on commit ed21b02

Please sign in to comment.