|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
3
|
|
|
# pylint: disable=unused-variable,unused-argument,expression-not-assigned |
|
4
|
|
|
|
|
5
|
|
|
from __future__ import unicode_literals |
|
6
|
|
|
|
|
7
|
|
|
import pytest |
|
|
|
|
|
|
8
|
|
|
from expecter import expect |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
from verchew.script import find_config, parse_config, get_version, _ |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
def describe_find_config(): |
|
14
|
|
|
|
|
15
|
|
|
@pytest.fixture |
|
16
|
|
|
def config(tmpdir): |
|
17
|
|
|
tmpdir.chdir() |
|
18
|
|
|
path = tmpdir.join("foo.bar") |
|
19
|
|
|
path.write("") |
|
20
|
|
|
return path |
|
21
|
|
|
|
|
22
|
|
|
def when_missing(config): |
|
23
|
|
|
with expect.raises(RuntimeError): |
|
24
|
|
|
find_config() |
|
25
|
|
|
|
|
26
|
|
|
def when_found(config): |
|
27
|
|
|
path = find_config(config_filenames=["foo.bar"]) |
|
28
|
|
|
|
|
29
|
|
|
expect(path) == config |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
def describe_parse_config(): |
|
33
|
|
|
|
|
34
|
|
|
@pytest.fixture |
|
35
|
|
|
def config(tmpdir): |
|
36
|
|
|
tmpdir.chdir() |
|
37
|
|
|
path = tmpdir.join("verchew.ini") |
|
38
|
|
|
path.write("") |
|
39
|
|
|
return path |
|
40
|
|
|
|
|
41
|
|
|
def with_no_content(config): |
|
42
|
|
|
config.write("") |
|
43
|
|
|
|
|
44
|
|
|
expect(parse_config(str(config))) == {} |
|
45
|
|
|
|
|
46
|
|
|
def with_an_empty_section(config): |
|
47
|
|
|
config.write(""" |
|
48
|
|
|
[Foobar] |
|
49
|
|
|
""".replace(' ' * 8, '')) |
|
50
|
|
|
|
|
51
|
|
|
expect(parse_config(str(config))) == { |
|
52
|
|
|
'Foobar': {}, |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
def with_a_filled_section(config): |
|
56
|
|
|
config.write(""" |
|
57
|
|
|
[Foobar] |
|
58
|
|
|
|
|
59
|
|
|
cli = foobar |
|
60
|
|
|
version = v1.2.3 |
|
61
|
|
|
""".replace(' ' * 8, '')) |
|
62
|
|
|
|
|
63
|
|
|
expect(parse_config(str(config))) == { |
|
64
|
|
|
'Foobar': { |
|
65
|
|
|
'cli': 'foobar', |
|
66
|
|
|
'version': 'v1.2.3', |
|
67
|
|
|
}, |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
def describe_get_version(): |
|
72
|
|
|
|
|
73
|
|
|
def when_missing(): |
|
74
|
|
|
expect(get_version('foobar')) == "sh: command not found: foobar" |
|
75
|
|
|
|
|
76
|
|
|
def when_found(): |
|
77
|
|
|
expect(get_version('python')).contains("Python ") |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
def describe_format(): |
|
81
|
|
|
|
|
82
|
|
|
def when_utf8(): |
|
83
|
|
|
expect(_('~', utf8=True)) == "✔" |
|
84
|
|
|
|
|
85
|
|
|
def when_tty(): |
|
86
|
|
|
expect(_('~', tty=True)) == "\033[92m~\033[0m" |
|
87
|
|
|
|
|
88
|
|
|
def when_utf8_and_tty(): |
|
89
|
|
|
expect(_('~', utf8=True, tty=True)) == "\033[92m✔\033[0m" |
|
90
|
|
|
|
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.