Completed
Push — init ( 57bb17 )
by Michael
06:45
created

git_repo()   A

Complexity

Conditions 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 13
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
}
35
36
@pytest.fixture
37
def git_repo():
38
    with CliRunner().isolated_filesystem():
39
        readme_path = 'README.md'
40
        open(readme_path, 'w').write(
41
            '\n'.join(README_MARKDOWN)
42
        )
43
        git('init')
44
        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 (87/79).

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

Loading history...
45
        git('add', 'README.md')
46
        git('commit', '-m', '"Please README"')
47
48
        yield
49
50
51
@pytest.fixture
52
def python_module(git_repo):
0 ignored issues
show
Comprehensibility Bug introduced by
git_repo is re-defining a name which is already available in the outer-scope (previously defined on line 37).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
53
    with CliRunner().isolated_filesystem():
54
        os.mkdir(PYTHON_MODULE)
55
56
        for file_path, content in FILE_CONTENT.items():
57
            open(file_path, 'w').write(
58
                '\n'.join(content)
59
            )
60
61
        yield
62