1
|
|
|
import os |
2
|
|
|
from click.testing import CliRunner |
|
|
|
|
3
|
|
|
import pytest |
4
|
|
|
|
5
|
|
|
from plumbum.cmd import git |
|
|
|
|
6
|
|
|
|
7
|
|
|
pytest_plugins = 'pytester' |
|
|
|
|
8
|
|
|
|
9
|
|
|
# TODO: textwrap.dedent.heredoc |
10
|
|
|
INIT_CONTENT = [ |
11
|
|
|
'"""A test app"""', |
12
|
|
|
'', |
13
|
|
|
"__version__ = '0.0.1'", |
14
|
|
|
"__url__ = 'https://github.com/someuser/test_app'", |
15
|
|
|
"__author__ = 'Some User'", |
16
|
|
|
"__email__ = '[email protected]'" |
17
|
|
|
] |
18
|
|
|
SETUP_PY = [ |
19
|
|
|
'from setuptools import setup', |
20
|
|
|
"setup(name='test_app'", |
21
|
|
|
] |
22
|
|
|
README_MARKDOWN = [ |
23
|
|
|
'# Test App', |
24
|
|
|
'', |
25
|
|
|
'This is the test application.' |
26
|
|
|
] |
27
|
|
|
|
28
|
|
|
PYTHON_MODULE = 'test_app' |
29
|
|
|
|
30
|
|
|
FILE_CONTENT = { |
31
|
|
|
'%s/__init__.py' % PYTHON_MODULE: INIT_CONTENT, |
32
|
|
|
'setup.py': SETUP_PY, |
33
|
|
|
'requirements.txt': ['pytest'], |
34
|
|
|
'README.md': README_MARKDOWN, |
35
|
|
|
'CHANGELOG.md': [''], |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
@pytest.fixture |
40
|
|
|
def git_repo(): |
41
|
|
|
with CliRunner().isolated_filesystem(): |
42
|
|
|
readme_path = 'README.md' |
43
|
|
|
open(readme_path, 'w').write( |
44
|
|
|
'\n'.join(README_MARKDOWN) |
45
|
|
|
) |
46
|
|
|
git_init([readme_path]) |
47
|
|
|
|
48
|
|
|
yield |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
def git_init(files_to_add): |
52
|
|
|
git('init') |
53
|
|
|
git('remote', 'add', 'origin', 'https://github.com/michaeljoseph/test_app.git') |
|
|
|
|
54
|
|
|
for file_to_add in files_to_add: |
55
|
|
|
git('add', file_to_add) |
56
|
|
|
git('commit', '-m', '"Initial commit"') |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
@pytest.fixture |
60
|
|
|
def python_module(): |
61
|
|
|
with CliRunner().isolated_filesystem(): |
62
|
|
|
os.mkdir(PYTHON_MODULE) |
63
|
|
|
|
64
|
|
|
for file_path, content in FILE_CONTENT.items(): |
65
|
|
|
open(file_path, 'w').write( |
66
|
|
|
'\n'.join(content) |
67
|
|
|
) |
68
|
|
|
|
69
|
|
|
git_init(FILE_CONTENT.keys()) |
70
|
|
|
|
71
|
|
|
yield |
72
|
|
|
|
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__.py
files in your module folders. Make sure that you place one file in each sub-folder.