Skip to content

Commit d9aaab7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into features
2 parents a87f6f8 + 9e0b19c commit d9aaab7

File tree

9 files changed

+27
-17
lines changed

9 files changed

+27
-17
lines changed

_pytest/compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def isclass(object):
129129
STRING_TYPES = bytes, str
130130
UNICODE_TYPES = str,
131131

132-
def _escape_strings(val):
132+
def _ascii_escaped(val):
133133
"""If val is pure ascii, returns it as a str(). Otherwise, escapes
134134
bytes objects into a sequence of escaped bytes:
135135
@@ -163,7 +163,7 @@ def _escape_strings(val):
163163

164164
from itertools import imap, izip # NOQA
165165

166-
def _escape_strings(val):
166+
def _ascii_escaped(val):
167167
"""In py2 bytes and str are the same type, so return if it's a bytes
168168
object, return it unchanged if it is a full ascii string,
169169
otherwise escape it into its binary form.

_pytest/hookspec.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,17 @@ def pytest_addoption(parser):
6060

6161
@hookspec(historic=True)
6262
def pytest_configure(config):
63-
""" called after command line options have been parsed
64-
and all plugins and initial conftest files been loaded.
65-
This hook is called for every plugin.
63+
"""
64+
Allows plugins and conftest files to perform initial configuration.
65+
66+
This hook is called for every plugin and initial conftest file
67+
after command line options have been parsed.
68+
69+
After that, the hook is called for other conftest files as they are
70+
imported.
71+
72+
:arg config: pytest config object
73+
:type config: _pytest.config.Config
6674
"""
6775

6876
# -------------------------------------------------------------------------

_pytest/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def pytest_addoption(parser):
4545
action="store", type=int, dest="maxfail", default=0,
4646
help="exit after first num failures or errors.")
4747
group._addoption('--strict', action="store_true",
48-
help="run pytest in strict mode, warnings become errors.")
48+
help="marks not registered in configuration file raise errors.")
4949
group._addoption("-c", metavar="file", type=str, dest="inifilename",
5050
help="load configuration from `file` instead of trying to locate one of the implicit configuration files.")
5151
group._addoption("--continue-on-collection-errors", action="store_true",

_pytest/python.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from _pytest import fixtures
1818
from _pytest import main
1919
from _pytest.compat import (
20-
isclass, isfunction, is_generator, _escape_strings,
20+
isclass, isfunction, is_generator, _ascii_escaped,
2121
REGEX_TYPE, STRING_TYPES, NoneType, NOTSET,
2222
get_real_func, getfslineno, safe_getattr,
2323
safe_str, getlocation, enum,
@@ -909,7 +909,7 @@ def _idval(val, argname, idx, idfn, config=None):
909909
msg += '\nUpdate your code as this will raise an error in pytest-4.0.'
910910
warnings.warn(msg, DeprecationWarning)
911911
if s:
912-
return _escape_strings(s)
912+
return _ascii_escaped(s)
913913

914914
if config:
915915
hook_id = config.hook.pytest_make_parametrize_id(
@@ -918,11 +918,11 @@ def _idval(val, argname, idx, idfn, config=None):
918918
return hook_id
919919

920920
if isinstance(val, STRING_TYPES):
921-
return _escape_strings(val)
921+
return _ascii_escaped(val)
922922
elif isinstance(val, (float, int, bool, NoneType)):
923923
return str(val)
924924
elif isinstance(val, REGEX_TYPE):
925-
return _escape_strings(val.pattern)
925+
return _ascii_escaped(val.pattern)
926926
elif enum is not None and isinstance(val, enum.Enum):
927927
return str(val)
928928
elif isclass(val) and hasattr(val, '__name__'):
@@ -938,7 +938,7 @@ def _idvalset(idx, parameterset, argnames, idfn, ids, config=None):
938938
for val, argname in zip(parameterset.values, argnames)]
939939
return "-".join(this_id)
940940
else:
941-
return _escape_strings(ids[idx])
941+
return _ascii_escaped(ids[idx])
942942

943943

944944
def idmaker(argnames, parametersets, idfn=None, ids=None, config=None):

changelog/2444.trivial

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update help message for ``--strict`` to make it clear it only deals with unregistered markers, not warnings.

changelog/2533.trivial

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Renamed the utility function `_pytest.compat._escape_strings` to `_ascii_escaped` to better communicate the function's purpose.

changelog/2539.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarify ``pytest_configure`` hook call order.

doc/en/example/markers.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,12 @@ For an example on how to add and work with markers from a plugin, see
223223

224224
It is recommended to explicitly register markers so that:
225225

226-
* there is one place in your test suite defining your markers
226+
* There is one place in your test suite defining your markers
227227

228-
* asking for existing markers via ``pytest --markers`` gives good output
228+
* Asking for existing markers via ``pytest --markers`` gives good output
229229

230-
* typos in function markers are treated as an error if you use
231-
the ``--strict`` option. Future versions of ``pytest`` are probably
232-
going to start treating non-registered markers as errors at some point.
230+
* Typos in function markers are treated as an error if you use
231+
the ``--strict`` option.
233232

234233
.. _`scoped-marking`:
235234

testing/test_skipping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ def test_strict_and_skip(self, testdir):
576576
def test_hello():
577577
pass
578578
""")
579-
result = testdir.runpytest("-rs --strict")
579+
result = testdir.runpytest("-rs")
580580
result.stdout.fnmatch_lines([
581581
"*unconditional skip*",
582582
"*1 skipped*",

0 commit comments

Comments
 (0)