tests.parse_args_test   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 13
eloc 33
dl 0
loc 47
rs 10
c 0
b 0
f 0

5 Functions

Rating   Name   Duplication   Size   Complexity  
A test_parse_args_no_args() 0 8 3
A test_parse_args_no_lang() 0 6 3
A test_parse_args_install_scripts() 0 3 2
A test_parse_args_pass() 0 5 2
A test_parse_args_no_name() 0 6 3
1
# -*- coding: utf-8 -*-
2
import sys
3
from unittest.mock import patch
4
5
import pytest
6
7
from dvnv.dvnv import parse_args
8
9
10
def test_parse_args_pass():
11
    with patch.object(sys, "argv", ["dvnv", "python", "dvnv"]):
12
        args = parse_args()
13
        assert args.lang == "python"
14
        assert args.name == "dvnv"
15
16
17
def test_parse_args_no_args(capsys):
18
    with patch.object(sys, "argv", ["dvnv", None, None]):
19
        with pytest.raises(SystemExit):
20
            parse_args()
21
            captured = capsys.readouterr()
22
            assert (
23
                captured.err
24
                == "[ERR] the following arguments are required: lang, name\n"
25
            )
26
27
28
def test_parse_args_no_lang(capsys):
29
    with patch.object(sys, "argv", ["dvnv", None, "test-project"]):
30
        with pytest.raises(SystemExit):
31
            parse_args()
32
            captured = capsys.readouterr()
33
            assert captured.err == "[ERR] the following arguments are required: lang\n"
34
35
36
def test_parse_args_no_name(capsys):
37
    with patch.object(sys, "argv", ["dvnv", "python", None]):
38
        with pytest.raises(SystemExit):
39
            parse_args()
40
            captured = capsys.readouterr()
41
            assert captured.err == "[ERR] the following arguments are required: name\n"
42
43
44
def test_parse_args_install_scripts():
45
    with patch.object(sys, "argv", ["dvnv", None, None, "--install_scripts"]):
46
        assert parse_args()
47