Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
213 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import pytest | ||
|
||
from wemake_python_styleguide.options.validation import ( | ||
validate_domain_names_options, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize(('allowed_names', 'forbidden_names'), [ | ||
(['items'], []), | ||
([], ['items']), | ||
(['item'], ['handle']), | ||
]) | ||
def test_passes_when_any_option_not_passed(allowed_names, forbidden_names): | ||
"""Ensures validation passes when any domain option not passed.""" | ||
validate_domain_names_options(allowed_names, forbidden_names) | ||
|
||
|
||
def test_passes_when_names_no_intersect(): | ||
"""Ensures validation passes when names no intersect.""" | ||
validate_domain_names_options(['node'], ['visitor']) | ||
|
||
|
||
def test_raises_valueerror_when_names_intersect(): | ||
"""Ensures `ValueError` exception is raised when names intersect.""" | ||
with pytest.raises(ValueError): | ||
validate_domain_names_options(['visitor', 'handle'], ['visitor']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from typing import FrozenSet | ||
|
||
from wemake_python_styleguide.constants import VARIABLE_NAMES_BLACKLIST | ||
from wemake_python_styleguide.types import ConfigurationOptions | ||
|
||
|
||
def variable_names_blacklist_from( | ||
options: ConfigurationOptions, | ||
) -> FrozenSet[str]: | ||
"""Creates variable names blacklist from options and constants.""" | ||
variable_names_blacklist = { | ||
*VARIABLE_NAMES_BLACKLIST, | ||
*options.forbidden_domain_names, | ||
} | ||
return frozenset( | ||
variable_names_blacklist - set(options.allowed_domain_names), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters