Skip to content

Commit

Permalink
test: tox.ini is applied with the default style
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoliwa committed Mar 9, 2021
1 parent e40c205 commit 610f832
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/nitpick/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
MANAGE_PY = "manage.py"
PRE_COMMIT_CONFIG_YAML = ".pre-commit-config.yaml"
EDITOR_CONFIG = ".editorconfig"
TOX_INI = "tox.ini"

SINGLE_QUOTE = "'"
DOUBLE_QUOTE = '"'
Expand Down
3 changes: 2 additions & 1 deletion tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from testfixtures import compare

from nitpick.constants import TOX_INI
from nitpick.generic import MergeDict, flatten, get_subclasses, relative_to_current_dir
from tests.helpers import assert_conditions

Expand Down Expand Up @@ -93,7 +94,7 @@ def test_relative_to_current_dir(home, cwd):
Path(project_dir): "",
f"{home_dir}{sep}another": f"{home_dir}{sep}another",
Path(f"{home_dir}{sep}bla{sep}bla"): f"{home_dir}{sep}bla{sep}bla",
f"{project_dir}{sep}tox.ini": "tox.ini",
f"{project_dir}{sep}{TOX_INI}": TOX_INI,
Path(f"{project_dir}{sep}apps{sep}manage.py"): f"apps{sep}manage.py",
f"{home_dir}{sep}another{sep}one{sep}bites.py": f"{home_dir}{sep}another{sep}one{sep}bites.py",
Path(f"{home_dir}{sep}bla{sep}bla.txt"): f"{home_dir}{sep}bla{sep}bla.txt",
Expand Down
30 changes: 27 additions & 3 deletions tests/test_ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from configupdater import ConfigUpdater

from nitpick.constants import EDITOR_CONFIG, SETUP_CFG
from nitpick.constants import EDITOR_CONFIG, SETUP_CFG, TOX_INI
from nitpick.plugins.ini import IniPlugin, Violations
from nitpick.violations import Fuss, SharedViolations
from tests.helpers import XFAIL_ON_WINDOWS, ProjectMock
Expand Down Expand Up @@ -65,11 +65,35 @@ def test_default_style_is_applied(project_with_default_style):
[Makefile]
indent_style = tab
"""
expected_tox_ini = """
[coverage:report]
precision = 2
show_missing = True
skip_covered = True
skip_empty = True
sort = Cover
[coverage:run]
branch = True
parallel = True
relative_files = True
source = src/
[testenv]
description = Run tests with pytest and coverage
extras = test
[tox]
isolated_build = True
"""
project_with_default_style.api_check_then_apply(
Fuss(True, SETUP_CFG, 321, " was not found. Create it with this content:", expected_setup_cfg),
Fuss(True, EDITOR_CONFIG, 321, " was not found. Create it with this content:", expected_editor_config),
partial_names=[SETUP_CFG, EDITOR_CONFIG],
).assert_file_contents(SETUP_CFG, expected_setup_cfg)
Fuss(True, TOX_INI, 321, " was not found. Create it with this content:", expected_tox_ini),
partial_names=[SETUP_CFG, EDITOR_CONFIG, TOX_INI],
).assert_file_contents(
SETUP_CFG, expected_setup_cfg, EDITOR_CONFIG, expected_editor_config, TOX_INI, expected_tox_ini
)


def test_comma_separated_keys_on_style_file(tmp_path):
Expand Down

0 comments on commit 610f832

Please sign in to comment.