Skip to content

Commit

Permalink
Added test to ensure parity between previous codes and versionchanged (
Browse files Browse the repository at this point in the history
…#869)

* Added test to ensure parity between previous codes and version
changed.

* Update test_docs.py
  • Loading branch information
Ben-Drebing authored and sobolevn committed Oct 16, 2019
1 parent 09742a9 commit 3e3ff7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ We used to have incremental versioning before `0.1.0`.
- Forbids using nested `typing.Literal`, `typing.Union` and `typing.Annotated`
- Forbids use of vague import names (e.g. `from json import loads`)
- Make ``OveruseOfNoqaCommentViolation`` configurable (`--max-noqa-comments`)
- Improves tests: we now ensure that each violation with previous codes also
has corresponding versions changed in their documentation
- Forbid incorrectly swapped variables
- Forbids to use `+=` with list arguments
- Forbids to use redundant subscripts (e.g., `[0:7]` or `[3:None]`)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_violations/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ def test_violation_name(all_violations):
assert class_name.endswith('Violation'), class_name


def test_previous_codes_versionchanged(all_violations):
"""Tests that we put both in case violation changes."""
for violation in all_violations:
previous_codes = getattr(violation, 'previous_codes', None)
if previous_codes is not None:
assert violation.__doc__.count(
'.. versionchanged::',
) >= len(violation.previous_codes)


def test_configuration(all_violations):
"""Ensures that all configuration options are listed in the docs."""
option_listed = {
Expand Down

0 comments on commit 3e3ff7a

Please sign in to comment.