diff --git a/_pytest/compat.py b/_pytest/compat.py index 0554efeb7..723283d6a 100644 --- a/_pytest/compat.py +++ b/_pytest/compat.py @@ -129,7 +129,7 @@ if _PY3: STRING_TYPES = bytes, str UNICODE_TYPES = str, - def _escape_strings(val): + def _ascii_escaped(val): """If val is pure ascii, returns it as a str(). Otherwise, escapes bytes objects into a sequence of escaped bytes: @@ -163,7 +163,7 @@ else: from itertools import imap, izip # NOQA - def _escape_strings(val): + def _ascii_escaped(val): """In py2 bytes and str are the same type, so return if it's a bytes object, return it unchanged if it is a full ascii string, otherwise escape it into its binary form. diff --git a/_pytest/hookspec.py b/_pytest/hookspec.py index 2c9a66163..f12aa87cc 100644 --- a/_pytest/hookspec.py +++ b/_pytest/hookspec.py @@ -60,9 +60,17 @@ def pytest_addoption(parser): @hookspec(historic=True) def pytest_configure(config): - """ called after command line options have been parsed - and all plugins and initial conftest files been loaded. - This hook is called for every plugin. + """ + Allows plugins and conftest files to perform initial configuration. + + This hook is called for every plugin and initial conftest file + after command line options have been parsed. + + After that, the hook is called for other conftest files as they are + imported. + + :arg config: pytest config object + :type config: _pytest.config.Config """ # ------------------------------------------------------------------------- diff --git a/_pytest/main.py b/_pytest/main.py index e6f679a37..1a6ba2781 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -45,7 +45,7 @@ def pytest_addoption(parser): action="store", type=int, dest="maxfail", default=0, help="exit after first num failures or errors.") group._addoption('--strict', action="store_true", - help="run pytest in strict mode, warnings become errors.") + help="marks not registered in configuration file raise errors.") group._addoption("-c", metavar="file", type=str, dest="inifilename", help="load configuration from `file` instead of trying to locate one of the implicit configuration files.") group._addoption("--continue-on-collection-errors", action="store_true", diff --git a/_pytest/python.py b/_pytest/python.py index 3750f61da..5a553aafc 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -17,7 +17,7 @@ import _pytest._pluggy as pluggy from _pytest import fixtures from _pytest import main from _pytest.compat import ( - isclass, isfunction, is_generator, _escape_strings, + isclass, isfunction, is_generator, _ascii_escaped, REGEX_TYPE, STRING_TYPES, NoneType, NOTSET, get_real_func, getfslineno, safe_getattr, safe_str, getlocation, enum, @@ -909,7 +909,7 @@ def _idval(val, argname, idx, idfn, config=None): msg += '\nUpdate your code as this will raise an error in pytest-4.0.' warnings.warn(msg, DeprecationWarning) if s: - return _escape_strings(s) + return _ascii_escaped(s) if config: hook_id = config.hook.pytest_make_parametrize_id( @@ -918,11 +918,11 @@ def _idval(val, argname, idx, idfn, config=None): return hook_id if isinstance(val, STRING_TYPES): - return _escape_strings(val) + return _ascii_escaped(val) elif isinstance(val, (float, int, bool, NoneType)): return str(val) elif isinstance(val, REGEX_TYPE): - return _escape_strings(val.pattern) + return _ascii_escaped(val.pattern) elif enum is not None and isinstance(val, enum.Enum): return str(val) elif isclass(val) and hasattr(val, '__name__'): @@ -938,7 +938,7 @@ def _idvalset(idx, parameterset, argnames, idfn, ids, config=None): for val, argname in zip(parameterset.values, argnames)] return "-".join(this_id) else: - return _escape_strings(ids[idx]) + return _ascii_escaped(ids[idx]) def idmaker(argnames, parametersets, idfn=None, ids=None, config=None): diff --git a/changelog/2444.trivial b/changelog/2444.trivial new file mode 100644 index 000000000..4d6e2de5b --- /dev/null +++ b/changelog/2444.trivial @@ -0,0 +1 @@ +Update help message for ``--strict`` to make it clear it only deals with unregistered markers, not warnings. diff --git a/changelog/2533.trivial b/changelog/2533.trivial new file mode 100644 index 000000000..cac4c3bdd --- /dev/null +++ b/changelog/2533.trivial @@ -0,0 +1 @@ +Renamed the utility function `_pytest.compat._escape_strings` to `_ascii_escaped` to better communicate the function's purpose. diff --git a/changelog/2539.doc b/changelog/2539.doc new file mode 100644 index 000000000..6d5a9c9db --- /dev/null +++ b/changelog/2539.doc @@ -0,0 +1 @@ +Clarify ``pytest_configure`` hook call order. diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index d74d16e9d..40338fba8 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -223,13 +223,12 @@ For an example on how to add and work with markers from a plugin, see It is recommended to explicitly register markers so that: - * there is one place in your test suite defining your markers + * There is one place in your test suite defining your markers - * asking for existing markers via ``pytest --markers`` gives good output + * Asking for existing markers via ``pytest --markers`` gives good output - * typos in function markers are treated as an error if you use - the ``--strict`` option. Future versions of ``pytest`` are probably - going to start treating non-registered markers as errors at some point. + * Typos in function markers are treated as an error if you use + the ``--strict`` option. .. _`scoped-marking`: diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 5f25c3e6e..5a6692b3c 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -576,7 +576,7 @@ class TestSkip(object): def test_hello(): pass """) - result = testdir.runpytest("-rs --strict") + result = testdir.runpytest("-rs") result.stdout.fnmatch_lines([ "*unconditional skip*", "*1 skipped*",