File: cli_test.py

package info (click to toggle)
identify 2.6.15-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: python: 6,533; makefile: 10
file content (31 lines) | stat: -rw-r--r-- 799 bytes parent folder | download | duplicates (3)
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
from __future__ import annotations

from identify import cli


def test_identify_cli(capsys):
    ret = cli.main(('setup.py',))
    out, _ = capsys.readouterr()
    assert ret == 0
    assert out == '["file", "non-executable", "python", "text"]\n'


def test_identify_cli_filename_only(capsys):
    ret = cli.main(('setup.py', '--filename-only'))
    out, _ = capsys.readouterr()
    assert ret == 0
    assert out == '["python", "text"]\n'


def test_identify_cli_filename_only_unidentified(capsys):
    ret = cli.main(('x.unknown', '--filename-only'))
    out, _ = capsys.readouterr()
    assert ret == 1
    assert out == ''


def test_file_not_found(capsys):
    ret = cli.main(('x.unknown',))
    out, _ = capsys.readouterr()
    assert ret == 1
    assert out == 'x.unknown does not exist.\n'