File: test_help.py

package info (click to toggle)
backblaze-b2 3.19.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,372 kB
  • sloc: python: 12,571; makefile: 21; sh: 12
file content (43 lines) | stat: -rw-r--r-- 1,265 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
31
32
33
34
35
36
37
38
39
40
41
42
43
######################################################################
#
# File: test/unit/console_tool/test_help.py
#
# Copyright 2023 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
import pytest


@pytest.mark.parametrize(
    "flag, included, excluded",
    [
        # --help shouldn't show deprecated commands
        (
            "--help",
            [" b2 download-file ", "-h", "--help-all"],
            [" download-file-by-name ", "(DEPRECATED)"],
        ),
        # --help-all should show deprecated commands, but marked as deprecated
        (
            "--help-all",
            ["(DEPRECATED) b2 download-file-by-name ", "-h", "--help-all"],
            [],
        ),
    ],
)
def test_help(b2_cli, flag, included, excluded, capsys):
    b2_cli.run([flag], expected_stdout=None)

    out = capsys.readouterr().out

    found = set()
    for i in included:
        if i in out:
            found.add(i)
    for e in excluded:
        if e in out:
            found.add(e)
    assert found.issuperset(included), f"expected {included!r} in {out!r}"
    assert found.isdisjoint(excluded), f"expected {excluded!r} not in {out!r}"