Completed
Push — init ( 57bb17...7b3c9c )
by Michael
08:49
created

git_init()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
1
import os
2
from click.testing import CliRunner
0 ignored issues
show
Configuration introduced by
The import click.testing could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
3
import pytest
4
5
from plumbum.cmd import git
0 ignored issues
show
Configuration introduced by
The import plumbum.cmd could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
6
7
pytest_plugins = 'pytester'
0 ignored issues
show
Coding Style Naming introduced by
The name pytest_plugins does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
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')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (83/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
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