File: test_cli_main.py

package info (click to toggle)
reuse 5.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,316 kB
  • sloc: python: 9,646; makefile: 80; sh: 6; ansic: 5
file content (30 lines) | stat: -rw-r--r-- 1,099 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# SPDX-FileCopyrightText: 2023 Carmen Bianca BAKKER <carmen@carmenbianca.eu>
# SPDX-FileCopyrightText: 2024 Free Software Foundation Europe e.V. <https://fsfe.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later

"""Tests for reuse.cli.main."""

from click.testing import CliRunner

from reuse import __version__
from reuse.cli.main import main


class TestMain:
    """Collect all tests for main."""

    def test_help_is_default(self):
        """--help is optional."""
        without_help = CliRunner().invoke(main, [])
        with_help = CliRunner().invoke(main, ["--help"])
        assert without_help.output == with_help.output
        assert without_help.exit_code == with_help.exit_code == 0
        assert with_help.output.startswith("Usage: reuse")

    def test_version(self):
        """--version returns the correct version."""
        result = CliRunner().invoke(main, ["--version"])
        assert result.output.startswith(f"reuse, version {__version__}\n")
        assert "This program is free software:" in result.output
        assert "GNU General Public License" in result.output