Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read configuration from pyproject.toml #58

Merged
merged 27 commits into from
Sep 2, 2020
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dce884b
Read configuration from `pyproject.toml` (#49)
akaihola Aug 16, 2020
0d53c71
Move argparse log level action to helpers module
akaihola Aug 19, 2020
4576337
Order and drop unused imports
akaihola Aug 19, 2020
78d2914
Add Darker configuration for the project itself
akaihola Aug 19, 2020
8de70ab
Satisfy pylint on modified lines
akaihola Aug 19, 2020
a52adf6
Refactor into function to avoid three repetitions
akaihola Aug 20, 2020
9f4b078
In configuration, allow to define paths to process
akaihola Aug 23, 2020
2ba5d6f
Disable Travis CI build for Python nightly
akaihola Aug 23, 2020
714f7b4
Fix configuration dump TOML list format - commas!
akaihola Aug 26, 2020
fce9e92
Return TOML dump as string, print by caller
akaihola Aug 26, 2020
799216e
Format modifications with Black 20.8b1 rules
akaihola Aug 26, 2020
c556ad4
Test formatting w/ pytest-darker, not pytest-black
akaihola Aug 26, 2020
633ea35
Convert Black configuration types
akaihola Aug 26, 2020
2385000
Fix diff tests
akaihola Aug 26, 2020
cfb1b5b
Find `pyproject.toml` based on paths to process
akaihola Aug 26, 2020
0d38c1c
Change log for Travis CI using Darker itself
akaihola Aug 27, 2020
d8f3991
Fix pyproject.toml reading using black 20.8b1
Mystic-Mirage Aug 26, 2020
9ea5a3c
Unit test for `make_argument_parser()`
akaihola Aug 27, 2020
8a93b8b
Unit test for `TomlArrayLinesEncoder`
akaihola Aug 28, 2020
990b294
Unit test for `replace_log_level_name()`
akaihola Aug 28, 2020
dfa1c32
Unit test for `load_config()`
akaihola Aug 28, 2020
818071d
Unit test for `get_effective_config()`
akaihola Aug 28, 2020
cf5fab2
Unit test for `get_modified_config()`
akaihola Aug 28, 2020
15e4752
'Refactored by Sourcery'
Aug 28, 2020
a99676d
Merge pull request #65 from akaihola/sourcery/config-file
akaihola Sep 2, 2020
bce3b22
Unit test for `dump_config()`
akaihola Sep 2, 2020
fc6c800
Unit test for `parse_command_line()`
akaihola Sep 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Unit test for get_modified_config()
  • Loading branch information
akaihola committed Aug 28, 2020
commit cf5fab2c6bcfdc037e471fb0fcee3627fef44651
25 changes: 24 additions & 1 deletion src/darker/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from argparse import Namespace
from argparse import ArgumentParser, Namespace
from textwrap import dedent

import pytest

from darker.config import (
TomlArrayLinesEncoder,
get_effective_config,
get_modified_config,
load_config,
replace_log_level_name,
)
Expand Down Expand Up @@ -191,3 +192,25 @@ def test_get_effective_config(args, expect):
result = get_effective_config(args)

assert result == expect


@pytest.mark.parametrize(
"args, expect",
[
(Namespace(), {}),
(Namespace(unknown="option"), {"unknown": "option"}),
(Namespace(log_level=10), {"log_level": "DEBUG"}),
(Namespace(names=[], int=42, string="fourty-two"), {"names": []}),
(Namespace(names=["bar"], int=42, string="fourty-two"), {"names": ["bar"]}),
(Namespace(names=["foo"], int=43, string="fourty-two"), {"int": 43}),
(Namespace(names=["foo"], int=42, string="one"), {"string": "one"}),
],
)
def test_get_modified_config(args, expect):
parser = ArgumentParser()
parser.add_argument("names", nargs="*", default=["foo"])
parser.add_argument("--int", dest="int", default=42)
parser.add_argument("--string", default="fourty-two")
result = get_modified_config(parser, args)

assert result == expect