1
|
|
|
import os |
2
|
|
|
|
3
|
|
|
import pytest |
4
|
|
|
from click.testing import CliRunner |
|
|
|
|
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
|
|
|
def git_init(files_to_add): |
40
|
|
|
git('init') |
41
|
|
|
git('remote', 'add', 'origin', 'https://github.com/michaeljoseph/test_app.git') |
|
|
|
|
42
|
|
|
for file_to_add in files_to_add: |
43
|
|
|
git('add', file_to_add) |
44
|
|
|
git('commit', '-m', 'Initial commit') |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
def github_merge_commit(): |
48
|
|
|
github = 'Merge pull request #111 from test_app/test-branch' |
49
|
|
|
git('checkout', '-b', 'test-branch') |
50
|
|
|
git('commit', '--allow-empty', '-m', 'Test branch commit message') |
51
|
|
|
git('checkout', 'master') |
52
|
|
|
git('merge', '--no-ff', 'test-branch') |
53
|
|
|
git('commit', '--allow-empty', '--amend', '-m', github) |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
@pytest.fixture |
57
|
|
|
def git_repo(): |
58
|
|
|
with CliRunner().isolated_filesystem(): |
59
|
|
|
readme_path = 'README.md' |
60
|
|
|
open(readme_path, 'w').write( |
61
|
|
|
'\n'.join(README_MARKDOWN) |
62
|
|
|
) |
63
|
|
|
git_init([readme_path]) |
64
|
|
|
|
65
|
|
|
yield |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
@pytest.fixture |
69
|
|
|
def git_repo_with_merge_commit(git_repo): |
|
|
|
|
70
|
|
|
github_merge_commit() |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
@pytest.fixture |
74
|
|
|
def python_module(): |
75
|
|
|
with CliRunner().isolated_filesystem(): |
76
|
|
|
os.mkdir(PYTHON_MODULE) |
77
|
|
|
|
78
|
|
|
for file_path, content in FILE_CONTENT.items(): |
79
|
|
|
open(file_path, 'w').write( |
80
|
|
|
'\n'.join(content) |
81
|
|
|
) |
82
|
|
|
|
83
|
|
|
git_init(FILE_CONTENT.keys()) |
84
|
|
|
|
85
|
|
|
yield |
86
|
|
|
|
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.