Skip to content

Commit

Permalink
docstrings: Use codespell to detect spelling errors
Browse files Browse the repository at this point in the history
CORRECTED:

* behave/*.py
* behave4cmd0/*.py
* tests/*.py
  • Loading branch information
jenisys committed Jun 16, 2024
1 parent 32256be commit eccf022
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 46 deletions.
13 changes: 8 additions & 5 deletions behave/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


class Unknown(object):
"""Placeholder for unknown/missing information, distinguishable from None.
"""
Placeholder for unknown/missing information, distinguishable from None.
.. code-block:: python
Expand All @@ -24,9 +25,10 @@ class Unknown(object):


class ExceptionUtil(object):
"""Provides a utility class for accessing/modifying exception information.
"""
Provides a utility class for accessing/modifying exception information.
.. seealso:: PEP-3134 Chained excpetions
.. seealso:: PEP-3134 Chained exceptions
"""
# pylint: disable=no-init

Expand Down Expand Up @@ -66,10 +68,11 @@ def describe(cls, exception, use_traceback=False, prefix=""):


class ChainedExceptionUtil(ExceptionUtil):
"""Provides a utility class for accessing/modifying exception information
"""
Provides a utility class for accessing/modifying exception information
related to chained exceptions.
.. seealso:: PEP-3134 Chained excpetions
.. seealso:: PEP-3134 Chained exceptions
"""
# pylint: disable=no-init

Expand Down
2 changes: 1 addition & 1 deletion behave/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def add(self, captured):
return self

def make_report(self):
"""Makes a detailled report of the captured output data.
"""Makes a detailed report of the captured output data.
:returns: Report as string.
"""
Expand Down
4 changes: 2 additions & 2 deletions behave/contrib/formatter_missing_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class MissingStepsFormatter(StepsUsageFormatter):
{step_snippets}
"""
name = "missing-steps"
description = "Writes implementation for missing step definitions."
name = "steps.missing"
description = "Shows undefined/missing steps definitions, implements them."
template = STEP_MODULE_TEMPLATE
scope = "behave.formatter.missing_steps"

Expand Down
4 changes: 2 additions & 2 deletions behave/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def use_fixture(fixture_func, context, *fixture_args, **fixture_kwargs):
"""Use fixture (function) and call it to perform its setup-part.
The fixture-function is similar to a :func:`contextlib.contextmanager`
(and contains a yield-statement to seperate setup and cleanup part).
(and contains a yield-statement to separate setup and cleanup part).
If it contains a yield-statement, it registers a context-cleanup function
to the context object to perform the fixture-cleanup at the end of the
current scoped when the context layer is removed
Expand Down Expand Up @@ -292,7 +292,7 @@ def use_composite_fixture_with(context, fixture_funcs_with_params):
safe-cleanup is needed even if an setup-fixture-error occurs.
This function ensures that fixture-cleanup is performed
for every fixture that was setup before the setup-error occured.
for every fixture that was setup before the setup-error occurred.
.. code-block:: python
Expand Down
4 changes: 3 additions & 1 deletion behave/formatter/_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
("tags.location", "behave.formatter.tags:TagsLocationFormatter"),
("steps", "behave.formatter.steps:StepsFormatter"),
("steps.doc", "behave.formatter.steps:StepsDocFormatter"),
("steps.bad", "behave.formatter.bad_steps:BadStepsFormatter"),
("steps.catalog", "behave.formatter.steps:StepsCatalogFormatter"),
("steps.code", "behave.formatter.steps_code:StepWithCodeFormatter"),
("steps.missing", "behave.contrib.formatter_missing_steps:MissingStepsFormatter"),
("steps.usage", "behave.formatter.steps:StepsUsageFormatter"),
("sphinx.steps", "behave.formatter.sphinx_steps:SphinxStepsFormatter"),
("bad_steps", "behave.formatter.bad_steps:BadStepsFormatter"),
]


# -----------------------------------------------------------------------------
# FUNCTIONS:
# -----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions behave/formatter/bad_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class BadStepsFormatter(Formatter):
Formatter that prints BAD_STEP_DEFINITIONS if any exist
at the end of the test-run.
"""
name = "bad_steps"
description = "Show BAD STEP-DEFINITION(s) (if any exist)"
name = "steps.bad"
description = "Shows BAD STEP-DEFINITION(s) (if any exist)."
PRINTER_CLASS = BadStepDefinitionCollector

def __init__(self, stream_opener, config):
Expand Down
4 changes: 2 additions & 2 deletions behave/formatter/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def scenario(self, scenario):
# self.stream.write("\n")

# -- PROGRESS FORMATTER DETAILS:
# @overriden
# @override
def report_feature_completed(self):
# -- SKIP: self.report_feature_duration()
has_scenarios = self.current_feature and self.current_scenario
Expand Down Expand Up @@ -294,6 +294,6 @@ def report_failures(self):
unicode_errors += 1

if unicode_errors:
msg = u"HINT: %d unicode errors occured during failure reporting.\n"
msg = u"HINT: %d unicode errors occurred during failure reporting.\n"
self.stream.write(msg % unicode_errors)
self.stream.flush()
4 changes: 2 additions & 2 deletions behave/formatter/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ class StepsCatalogFormatter(StepsDocFormatter):
step definitions. The primary purpose is to provide help for a test writer.
In order to ease work for non-programmer testers, the technical details of
the steps (i.e. function name, source location) are ommited and the
steps are shown as they would apprear in a feature file (no noisy '@',
the steps (i.e. function name, source location) are omitted and the
steps are shown as they would appear in a feature file (no noisy '@',
or '(', etc.).
Also, the output is sorted by step type (Given, When, Then)
Expand Down
2 changes: 1 addition & 1 deletion behave/matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class MatchWithError(Match):
"""Match class when error occur during step-matching
REASON:
* Type conversion error occured.
* Type conversion error occurred.
* ...
"""
def __init__(self, func, error):
Expand Down
10 changes: 5 additions & 5 deletions behave/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class ScenarioContainer(TagAndStatusStatement, Replayable):
.. attribute:: hook_failed
Indicates if a hook failure occured while running this feature.
Indicates if a hook failure occurred while running this feature.
.. attribute:: filename
Expand Down Expand Up @@ -503,7 +503,7 @@ class Feature(ScenarioContainer):
.. attribute:: hook_failed
Indicates if a hook failure occured while running this feature.
Indicates if a hook failure occurred while running this feature.
.. versionadded:: 1.2.6
Expand Down Expand Up @@ -647,7 +647,7 @@ class Rule(ScenarioContainer):
.. attribute:: hook_failed
Indicates if a hook failure occured while running this feature.
Indicates if a hook failure occurred while running this feature.
.. versionadded:: 1.2.6
Expand Down Expand Up @@ -896,7 +896,7 @@ class Scenario(TagAndStatusStatement, Replayable):
.. attribute:: hook_failed
Indicates if a hook failure occured while running this scenario.
Indicates if a hook failure occurred while running this scenario.
.. versionadded:: 1.2.6
Expand Down Expand Up @@ -1693,7 +1693,7 @@ class Step(BasicStatement, Replayable):
.. attribute:: hook_failed
Indicates if a hook failure occured while running this step.
Indicates if a hook failure occurred while running this step.
.. versionadded:: 1.2.6
Expand Down
2 changes: 1 addition & 1 deletion behave/model_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Status(Enum):
* executing: Marks the steps during execution (used in a formatter)
.. versionadded:: 1.2.6
Superceeds string-based status values.
Supersedes string-based status values.
"""
untested = 0
skipped = 1
Expand Down
4 changes: 2 additions & 2 deletions behave/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def ask_parse_failure_oracle(self, line):
Oracle, oracle, ... what went wrong?
:param line: Text line where parse failure occured (as string).
:param line: Text line where parse failure occurred (as string).
:return: Reason (as string) if an explanation is found.
Otherwise, empty string or None.
"""
Expand Down Expand Up @@ -699,7 +699,7 @@ def action_table(self, line):
self.feature.filename, self.line)

# -- SUPPORT: Escaped-pipe(s) in Gherkin cell values.
# Search for pipe(s) that are not preceeded with an escape char.
# Search for pipe(s) that are not preceded with an escape char.
cells = [cell.replace("\\|", "|").strip()
for cell in re.split(r"(?<!\\)\|", line[1:-1])]
if self.table is None:
Expand Down
2 changes: 1 addition & 1 deletion behave/tag_expression/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
Common module for tag-expressions:
* v1: old tag expressions (deprecating; superceeded by: cucumber-tag-expressions)
* v1: old tag expressions (deprecating; superseded by: cucumber-tag-expressions)
* v2: cucumber-tag-expressions (with wildcard extension)
.. seealso::
Expand Down
4 changes: 2 additions & 2 deletions behave4cmd0/step_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def print_differences(actual, expected):
@contextlib.contextmanager
def on_assert_failed_print_details(actual, expected):
"""
Print text details in case of assertation failed errors.
Print text details in case of assertion failed errors.
.. sourcecode:: python
Expand All @@ -47,7 +47,7 @@ def on_assert_failed_print_details(actual, expected):
@contextlib.contextmanager
def on_error_print_details(actual, expected):
"""
Print text details in case of assertation failed errors.
Print text details in case of assertion failed errors.
.. sourcecode:: python
Expand Down
2 changes: 1 addition & 1 deletion behave4cmd0/textutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def text_normalize(text):
"""
# if not isinstance(text, str):
if isinstance(text, bytes):
# -- MAYBE: command.ouput => bytes, encoded stream output.
# -- MAYBE: command.output => bytes, encoded stream output.
text = codecs.decode(text)
lines = [ line.strip() for line in text.splitlines() if line.strip() ]
return "\n".join(lines)
Expand Down
3 changes: 2 additions & 1 deletion features/formatter.help.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Feature: Help Formatter
And the command output should contain:
"""
AVAILABLE FORMATTERS:
bad_steps Show BAD STEP-DEFINITION(s) (if any exist)
json JSON dump of test run
json.pretty JSON dump of test run (human readable)
null Provides formatter that does not output anything.
Expand All @@ -37,9 +36,11 @@ Feature: Help Formatter
rerun Emits scenario file locations of failing scenarios
sphinx.steps Generate sphinx-based documentation for step definitions.
steps Shows step definitions (step implementations).
steps.bad Shows BAD STEP-DEFINITION(s) (if any exist).
steps.catalog Shows non-technical documentation for step definitions.
steps.code Shows executed steps combined with their code.
steps.doc Shows documentation for step definitions.
steps.missing Shows undefined/missing steps definitions, implements them.
steps.usage Shows how step definitions are used by steps.
tags Shows tags (and how often they are used).
tags.location Shows tags and the location where they are used.
Expand Down
1 change: 0 additions & 1 deletion issue.features/issue0031.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Feature: Issue #31 "behave --format help" raises an error
And the command output should contain:
"""
AVAILABLE FORMATTERS:
bad_steps Show BAD STEP-DEFINITION(s) (if any exist)
json JSON dump of test run
json.pretty JSON dump of test run (human readable)
null Provides formatter that does not output anything.
Expand Down
8 changes: 8 additions & 0 deletions py.requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ sphinx-intl >= 0.9.11

sphinxcontrib-applehelp >= 1.0.8; python_version >= '3.7'
sphinxcontrib-htmlhelp >= 2.0.5; python_version >= '3.7'

# EXPERIMENTAL:
# -- DOCUMENTATION WRITING HELPERS:
# SEE: https://github.com/codespell-project/codespell
codespell >= 2.3.0; python_version >= '3.8'

# SEE: https://github.com/amperser/proselint
proselint >= 0.14.0; python_version >= '3.8'
2 changes: 1 addition & 1 deletion tests/api/_test_async_step34.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def when_async_step_raises_exception(context):
1 / 0 # XFAIL-HERE: Raises ZeroDivisionError

# pylint: enable=import-outside-toplevel, unused-argument
# -- RUN ASYNC-STEP: Verify that raised exeception is detected.
# -- RUN ASYNC-STEP: Verify that raised exception is detected.
context = Context(runner=Runner(config={}))
with pytest.raises(ZeroDivisionError):
when_async_step_raises_exception(context)
4 changes: 2 additions & 2 deletions tests/api/test_async_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
_python_version = sys.version_info[:2]
if _python_version >= (3, 4):
# -- PROTECTED-IMPORT:
# Older Python version have problems with grammer extensions (yield-from).
# Older Python version have problems with grammar extensions (yield-from).
# from ._test_async_step34 import TestAsyncStepDecorator34
# from ._test_async_step34 import TestAsyncContext, TestAsyncStepRun34
from ._test_async_step34 import * # noqa: F403
if _python_version >= (3, 5):
# -- PROTECTED-IMPORT:
# Older Python version have problems with grammer extensions (async/await).
# Older Python version have problems with grammar extensions (async/await).
# from ._test_async_step35 import TestAsyncStepDecorator35, TestAsyncStepRun35
from ._test_async_step35 import * # noqa: F403
2 changes: 1 addition & 1 deletion tests/issues/test_issue0449.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def foo(stop):
And I also have UTF-8 as my console charset. Running this code leads to
"Assertion Failed: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)" error.
That is becase behave.textutil.text returns six.text_type(e) where 'e' is exception (https://github.com/behave/behave/blob/master/behave/textutil.py#L83).
That is because behave.textutil.text returns six.text_type(e) where 'e' is exception (https://github.com/behave/behave/blob/master/behave/textutil.py#L83).
Changing line 83 to six.text_type(value) solves this issue.
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/issues/test_issue0495.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SimpleContext(object): pass
# -----------------------------------------------------------------------------
@pytest.mark.parametrize("log_message", [
u"Hello Alice", # case: unproblematic (GOOD CASE)
u"Ärgernis ist überall", # case: unicode-string
u"Ärgernis ist überall", # case: unicode-string # codespell:ignore ist
"Ärgernis", # case: byte-string (use encoding-declaration above)
])
def test_issue(log_message):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_ansi_escapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def colorize_text(text, colors=None):
# TEST SUITE
# --------------------------------------------------------------------------
def test_module_setup():
"""Ensure that the module setup (aliases, escapes) occured."""
"""Ensure that the module setup (aliases, escapes) occurred."""
# colors_count = len(ansi_escapes.colors)
aliases_count = len(ansi_escapes.aliases)
escapes_count = len(ansi_escapes.escapes)
Expand Down
13 changes: 8 additions & 5 deletions tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,12 +1280,14 @@ def test_parses_french(self):
])

def test_parses_french_multi_word(self):
# codespell:ignore donné
doc = u"""
Fonctionnalit\xe9: testing stuff
Fonctionnalité: testing stuff
Oh my god, it's full of stuff...
Sc\xe9nario: test stuff
Etant donn\xe9 I am testing stuff
Scénario: test stuff
# codespell:ignore donné
Etant donné I am testing stuff
Alors it should work
""".lstrip()
feature = parse_feature(doc, 'fr')
Expand All @@ -1294,9 +1296,10 @@ def test_parses_french_multi_word(self):

assert len(feature.scenarios) == 1
assert feature.scenarios[0].name == "test stuff"
# codespell:ignore donné
assert_compare_steps(feature.scenarios[0].steps, [
('given', u'Etant donn\xe9', 'I am testing stuff', None, None),
('then', 'Alors', 'it should work', None, None),
("given", u"Etant donné", u"I am testing stuff", None, None),
("then", u"Alors", u"it should work", None, None),
])
test_parses_french_multi_word.go = 1

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_textutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ def test_text__with_assert_failed_and_unicode_message(self, message):
def test_text__with_assert_failed_and_bytes_message(self, message):
# -- ONLY PYTHON2: Use case makes no sense for Python 3.
bytes_message = message.encode(self.ENCODING)
decode_error_occured = False
decode_error_occurred = False
with pytest.raises(AssertionError) as e:
try:
assert False, bytes_message
except UnicodeDecodeError as uni_error:
# -- SINCE: Python 2.7.15
decode_error_occured = True
decode_error_occurred = True
expected_decode_error = "'ascii' codec can't decode byte 0xc3 in position 0"
assert expected_decode_error in str(uni_error)
assert False, bytes_message.decode(self.ENCODING)

# -- FOR: pytest < 5.0
# expected = u"AssertionError: %s" % message
print("decode_error_occured(ascii)=%s" % decode_error_occured)
print("decode_error_occurred(ascii)=%s" % decode_error_occurred)
text2 = text(e.value)
assert message in text2, "OOPS: text=%r" % text2

Expand Down

0 comments on commit eccf022

Please sign in to comment.