Skip to content

Commit

Permalink
rename the plugin example and its rule
Browse files Browse the repository at this point in the history
  • Loading branch information
ssato committed Oct 4, 2020
1 parent 1c5c6a4 commit db749b4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/plugins/example/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"""
from __future__ import absolute_import

from . import override_comments
from . import forbid_comments


RULES = (
(override_comments.ID, override_comments),
(forbid_comments.ID, forbid_comments),
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Use this rule to override some comments' rules.
Use this rule to forbid comments.
.. rubric:: Options
Expand All @@ -24,7 +24,7 @@
.. rubric:: Examples
#. With ``override-comments: {forbid: true}``
#. With ``forbid-comments: {forbid: true}``
the following code snippet would **PASS**:
::
Expand All @@ -42,14 +42,14 @@
.. code-block:: yaml
rules:
override-comments:
forbid-comments:
forbid: False
"""
from yamllint.linter import LintProblem


ID = 'override-comments'
ID = 'forbid-comments'
TYPE = 'comment'
CONF = {'forbid': bool}
DEFAULT = {'forbid': False}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ class PluginFunctionsTestCase(unittest.TestCase):

def test_validate_rule_module(self):
fun = yamllint.plugins.validate_rule_module
rule_mod = example.override_comments
rule_mod = example.forbid_comments

self.assertFalse(fun(object()))
self.assertTrue(fun(rule_mod))

@unittest.skipIf(not mock, "unittest.mock is not available")
def test_validate_rule_module_using_mock(self):
fun = yamllint.plugins.validate_rule_module
rule_mod = example.override_comments
rule_mod = example.forbid_comments

with mock.patch.object(rule_mod, "ID", False):
self.assertFalse(fun(rule_mod))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def test_get_default_rule_with_plugins(self):
yamllint.rules.braces)

def test_get_plugin_rules(self):
plugin_rule_id = example.override_comments.ID
plugin_rule_mod = example.override_comments
plugin_rule_id = example.forbid_comments.ID
plugin_rule_mod = example.forbid_comments

with mock.patch.dict(yamllint.rules._EXTERNAL_RULES, PLUGIN_RULES):
self.assertEqual(yamllint.rules.get(plugin_rule_id),
Expand Down

0 comments on commit db749b4

Please sign in to comment.