From 18024467ffb7c1a6f95eddd31d6d6f18b763b84c Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sun, 12 May 2019 19:14:06 +0300 Subject: [PATCH 01/22] Fix invalid Python file encoding "utf8" Since Python 3 it must be "utf-8", which is the official name. This is backwards compatible with Python 2. --- testing/test_capture.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test_capture.py b/testing/test_capture.py index 5d80eb63d..0dc2c42d8 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -106,7 +106,7 @@ def test_capturing_unicode(testdir, method): obj = "u'\u00f6y'" testdir.makepyfile( """ - # coding=utf8 + # coding=utf-8 # taken from issue 227 from nosetests def test_unicode(): import sys From 7573747cda7536c7d15595dc1d03c513b387743c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 14 May 2019 19:42:44 -0300 Subject: [PATCH 02/22] Normalize all source encoding declarations --- src/_pytest/skipping.py | 2 +- testing/acceptance_test.py | 2 +- testing/code/test_excinfo.py | 2 +- testing/code/test_source.py | 2 +- testing/io/test_saferepr.py | 2 +- testing/logging/test_fixture.py | 2 +- testing/logging/test_reporting.py | 4 ++-- testing/python/collect.py | 6 +++--- testing/python/fixtures.py | 2 +- testing/python/metafunc.py | 2 +- testing/python/show_fixtures_per_test.py | 2 +- testing/test_assertion.py | 4 ++-- testing/test_assertrewrite.py | 8 ++++---- testing/test_capture.py | 4 ++-- testing/test_doctest.py | 2 +- testing/test_junitxml.py | 2 +- testing/test_pluginmanager.py | 4 ++-- testing/test_pytester.py | 2 +- testing/test_runner.py | 4 ++-- testing/test_skipping.py | 2 +- testing/test_warnings.py | 8 ++++---- 21 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 1d70fb153..94a43de49 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -1,4 +1,4 @@ -# coding=utf8 +# coding: utf-8 """ support for skip/xfail functions and markers. """ from __future__ import absolute_import from __future__ import division diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index b0c682900..a6bf93459 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index a76797301..09e96a45f 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 0a2a98c02..7a9e8b79f 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 # flake8: noqa # disable flake check on this file because some constructs are strange # or redundant on purpose and can't be disable on a line-by-line basis diff --git a/testing/io/test_saferepr.py b/testing/io/test_saferepr.py index 901203088..abee94999 100644 --- a/testing/io/test_saferepr.py +++ b/testing/io/test_saferepr.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from _pytest._io.saferepr import saferepr diff --git a/testing/logging/test_fixture.py b/testing/logging/test_fixture.py index ff772e7ec..89065b086 100644 --- a/testing/logging/test_fixture.py +++ b/testing/logging/test_fixture.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 import logging import pytest diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 77cf71b43..ce6892492 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 import os import re from io import open @@ -842,7 +842,7 @@ def test_log_file_unicode(testdir): ) testdir.makepyfile( """ - # -*- coding: utf-8 -*- + # coding: utf-8 from __future__ import unicode_literals import logging diff --git a/testing/python/collect.py b/testing/python/collect.py index 9430bcaa1..3b5e9dd42 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 import os import sys import textwrap @@ -119,7 +119,7 @@ class TestModule(object): """ testdir.makepyfile( u""" - # -*- coding: utf-8 -*- + # coding: utf-8 raise ImportError(u'Something bad happened ☺') """ ) @@ -1244,7 +1244,7 @@ def test_syntax_error_with_non_ascii_chars(testdir): """ testdir.makepyfile( u""" - # -*- coding: UTF-8 -*- + # coding: utf-8 ☃ """ diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 18ede4006..2f64b1be2 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 import sys import textwrap diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 29f18da36..2a84a7a57 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 import re import sys import textwrap diff --git a/testing/python/show_fixtures_per_test.py b/testing/python/show_fixtures_per_test.py index e14344d4e..f677b3067 100644 --- a/testing/python/show_fixtures_per_test.py +++ b/testing/python/show_fixtures_per_test.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 def test_no_items_should_not_show_output(testdir): diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 8a59b7e8d..7d92b1bac 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -1297,7 +1297,7 @@ def test_assert_indirect_tuple_no_warning(testdir): def test_assert_with_unicode(monkeypatch, testdir): testdir.makepyfile( u""" - # -*- coding: utf-8 -*- + # coding: utf-8 def test_unicode(): assert u'유니코드' == u'Unicode' """ diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 87dada213..5b527ca22 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -960,7 +960,7 @@ class TestAssertionRewriteHookDetails(object): def test_detect_coding_cookie(self, testdir): testdir.makepyfile( test_cookie=""" - # -*- coding: utf-8 -*- + # coding: utf-8 u"St\xc3\xa4d" def test_rewritten(): assert "@py_builtins" in globals()""" @@ -971,7 +971,7 @@ class TestAssertionRewriteHookDetails(object): def test_detect_coding_cookie_second_line(self, testdir): testdir.makepyfile( test_cookie=""" - # -*- coding: utf-8 -*- + # coding: utf-8 u"St\xc3\xa4d" def test_rewritten(): assert "@py_builtins" in globals()""" @@ -982,7 +982,7 @@ class TestAssertionRewriteHookDetails(object): def test_detect_coding_cookie_crlf(self, testdir): testdir.makepyfile( test_cookie=""" - # -*- coding: utf-8 -*- + # coding: utf-8 u"St\xc3\xa4d" def test_rewritten(): assert "@py_builtins" in globals()""" diff --git a/testing/test_capture.py b/testing/test_capture.py index 0dc2c42d8..42bb4b8aa 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -106,7 +106,7 @@ def test_capturing_unicode(testdir, method): obj = "u'\u00f6y'" testdir.makepyfile( """ - # coding=utf-8 + # coding: utf-8 # taken from issue 227 from nosetests def test_unicode(): import sys diff --git a/testing/test_doctest.py b/testing/test_doctest.py index db6c4c2d3..164fdc423 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -658,7 +658,7 @@ class TestDoctests(object): """ p = testdir.makepyfile( test_unicode_doctest_module=""" - # -*- encoding: utf-8 -*- + # encoding: utf-8 from __future__ import unicode_literals def fix_bad_unicode(text): diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index cca0143a2..41b27e275 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 12990c867..423a20c29 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -1,4 +1,4 @@ -# encoding: UTF-8 +# encoding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -155,7 +155,7 @@ def test_importplugin_error_message(testdir, pytestpm): testdir.syspathinsert(testdir.tmpdir) testdir.makepyfile( qwe=""" - # encoding: UTF-8 + # encoding: utf-8 def test_traceback(): raise ImportError(u'Not possible to import: ☺') test_traceback() diff --git a/testing/test_pytester.py b/testing/test_pytester.py index b76d413b7..bf6e5d97e 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_runner.py b/testing/test_runner.py index c52d2ea7c..7ab63b346 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -793,7 +793,7 @@ def test_pytest_cmdline_main(testdir): def test_unicode_in_longrepr(testdir): testdir.makeconftest( """ - # -*- coding: utf-8 -*- + # coding: utf-8 import pytest @pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(): diff --git a/testing/test_skipping.py b/testing/test_skipping.py index fb0822f8f..8df726bc8 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -1,4 +1,4 @@ -# coding=utf8 +# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_warnings.py b/testing/test_warnings.py index 0daa466b7..ce157cbed 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -1,4 +1,4 @@ -# -*- coding: utf8 -*- +# coding: utf-8 from __future__ import unicode_literals import sys @@ -133,7 +133,7 @@ def test_ignore(testdir, pyfile_with_warnings, method): def test_unicode(testdir, pyfile_with_warnings): testdir.makepyfile( """ - # -*- coding: utf8 -*- + # coding: utf-8 import warnings import pytest @@ -168,7 +168,7 @@ def test_py2_unicode(testdir, pyfile_with_warnings): pytest.xfail("fails with unicode error on PyPy2 5.9 and Windows (#2905)") testdir.makepyfile( """ - # -*- coding: utf8 -*- + # coding: utf-8 import warnings import pytest @@ -577,7 +577,7 @@ def test_infinite_loop_warning_against_unicode_usage_py2(testdir): """ testdir.makepyfile( """ - # -*- coding: utf8 -*- + # coding: utf-8 from __future__ import unicode_literals import warnings import pytest From dc75b6af47abd06332b28ff4857172ba838f4fe4 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 14 May 2019 15:56:31 -0700 Subject: [PATCH 03/22] Use fix-encoding-pragma pre-commit hook --- .pre-commit-config.yaml | 1 + bench/bench.py | 1 + bench/bench_argcomplete.py | 1 + bench/empty.py | 1 + bench/manyparam.py | 1 + bench/skip.py | 1 + doc/en/_themes/flask_theme_support.py | 1 + doc/en/conftest.py | 1 + doc/en/example/assertion/failure_demo.py | 1 + .../assertion/global_testmodule_config/conftest.py | 1 + .../global_testmodule_config/test_hello_world.py | 1 + doc/en/example/assertion/test_failures.py | 1 + doc/en/example/assertion/test_setup_flow_example.py | 1 + doc/en/example/conftest.py | 1 + doc/en/example/costlysetup/conftest.py | 1 + doc/en/example/costlysetup/sub_a/__init__.py | 1 + doc/en/example/costlysetup/sub_a/test_quick.py | 1 + doc/en/example/costlysetup/sub_b/__init__.py | 1 + doc/en/example/costlysetup/sub_b/test_two.py | 1 + doc/en/example/multipython.py | 1 + doc/en/example/nonpython/conftest.py | 1 + doc/en/example/py2py3/conftest.py | 1 + doc/en/example/py2py3/test_py3.py | 1 + doc/en/example/pythoncollection.py | 1 + doc/en/example/xfail_demo.py | 1 + extra/get_issues.py | 1 + extra/setup-py.test/setup.py | 1 + scripts/release.py | 1 + setup.py | 1 + src/_pytest/__init__.py | 1 + src/_pytest/_argcomplete.py | 1 + src/_pytest/_code/__init__.py | 1 + src/_pytest/_code/_py2traceback.py | 1 + src/_pytest/_code/code.py | 1 + src/_pytest/_code/source.py | 1 + src/_pytest/_io/saferepr.py | 1 + src/_pytest/assertion/__init__.py | 1 + src/_pytest/assertion/rewrite.py | 1 + src/_pytest/assertion/truncate.py | 1 + src/_pytest/assertion/util.py | 1 + src/_pytest/cacheprovider.py | 1 + src/_pytest/capture.py | 1 + src/_pytest/compat.py | 1 + src/_pytest/config/__init__.py | 1 + src/_pytest/config/argparsing.py | 1 + src/_pytest/config/exceptions.py | 1 + src/_pytest/config/findpaths.py | 1 + src/_pytest/debugging.py | 1 + src/_pytest/deprecated.py | 1 + src/_pytest/doctest.py | 1 + src/_pytest/fixtures.py | 1 + src/_pytest/freeze_support.py | 1 + src/_pytest/helpconfig.py | 1 + src/_pytest/hookspec.py | 1 + src/_pytest/junitxml.py | 1 + src/_pytest/logging.py | 1 + src/_pytest/main.py | 1 + src/_pytest/mark/__init__.py | 1 + src/_pytest/mark/evaluate.py | 1 + src/_pytest/mark/legacy.py | 1 + src/_pytest/mark/structures.py | 1 + src/_pytest/monkeypatch.py | 1 + src/_pytest/nodes.py | 1 + src/_pytest/nose.py | 1 + src/_pytest/outcomes.py | 1 + src/_pytest/pastebin.py | 1 + src/_pytest/pathlib.py | 1 + src/_pytest/pytester.py | 1 + src/_pytest/python.py | 1 + src/_pytest/python_api.py | 1 + src/_pytest/recwarn.py | 1 + src/_pytest/reports.py | 1 + src/_pytest/resultlog.py | 1 + src/_pytest/runner.py | 1 + src/_pytest/setuponly.py | 1 + src/_pytest/setupplan.py | 1 + src/_pytest/skipping.py | 2 +- src/_pytest/stepwise.py | 1 + src/_pytest/terminal.py | 2 +- src/_pytest/tmpdir.py | 1 + src/_pytest/unittest.py | 1 + src/_pytest/warning_types.py | 1 + src/_pytest/warnings.py | 1 + src/pytest.py | 1 + testing/acceptance_test.py | 2 +- testing/code/test_code.py | 2 +- testing/code/test_excinfo.py | 2 +- testing/code/test_source.py | 2 +- testing/conftest.py | 1 + testing/deprecated_test.py | 1 + .../acceptance/fixture_mock_integration.py | 1 + .../collect/collect_init_tests/tests/__init__.py | 1 + .../collect/collect_init_tests/tests/test_foo.py | 1 + .../collect/package_infinite_recursion/conftest.py | 1 + .../package_infinite_recursion/tests/test_basic.py | 1 + .../collect/package_init_given_as_arg/pkg/test_foo.py | 1 + .../config/collect_pytest_prefix/conftest.py | 1 + .../config/collect_pytest_prefix/test_foo.py | 1 + testing/example_scripts/conftest_usageerror/conftest.py | 1 + .../dataclasses/test_compare_dataclasses.py | 1 + .../test_compare_dataclasses_field_comparison_off.py | 1 + .../dataclasses/test_compare_dataclasses_verbose.py | 1 + .../dataclasses/test_compare_two_different_dataclasses.py | 1 + .../deprecated/test_fixture_named_request.py | 1 + testing/example_scripts/fixtures/custom_item/conftest.py | 1 + .../example_scripts/fixtures/custom_item/foo/test_foo.py | 1 + .../sub1/conftest.py | 1 + .../sub1/test_in_sub1.py | 1 + .../sub2/conftest.py | 1 + .../sub2/test_in_sub2.py | 1 + .../test_detect_recursive_dependency_error.py | 1 + .../test_extend_fixture_conftest_conftest/conftest.py | 1 + .../test_extend_fixture_conftest_conftest/pkg/conftest.py | 1 + .../pkg/test_spam.py | 1 + .../test_extend_fixture_conftest_module/conftest.py | 1 + .../test_extend_fixture_conftest_module.py | 1 + .../fill_fixtures/test_extend_fixture_module_class.py | 1 + .../fixtures/fill_fixtures/test_funcarg_basic.py | 1 + .../fill_fixtures/test_funcarg_lookup_classlevel.py | 1 + .../fill_fixtures/test_funcarg_lookup_modulelevel.py | 1 + .../fixtures/fill_fixtures/test_funcarg_lookupfails.py | 1 + .../fixtures/test_getfixturevalue_dynamic.py | 1 + .../issue88_initial_file_multinodes/conftest.py | 1 + .../issue88_initial_file_multinodes/test_hello.py | 1 + testing/example_scripts/issue_519.py | 1 + .../marks_considered_keywords/test_marks_as_keywords.py | 1 + .../perf_examples/collect_stats/generate_folders.py | 1 + .../perf_examples/collect_stats/template_test.py | 1 + testing/example_scripts/tmpdir/tmpdir_fixture.py | 1 + .../unittest/test_parametrized_fixture_error_message.py | 1 + testing/example_scripts/unittest/test_setup_skip.py | 1 + testing/example_scripts/unittest/test_setup_skip_class.py | 1 + .../example_scripts/unittest/test_setup_skip_module.py | 1 + .../warnings/test_group_warnings_by_message.py | 1 + testing/examples/test_issue519.py | 1 + testing/freeze/create_executable.py | 1 + testing/freeze/runtests_script.py | 1 + testing/freeze/tests/test_trivial.py | 1 + testing/freeze/tox_run.py | 1 + testing/io/test_saferepr.py | 2 +- testing/logging/test_fixture.py | 2 +- testing/logging/test_formatter.py | 1 + testing/logging/test_reporting.py | 4 ++-- testing/python/approx.py | 2 +- testing/python/collect.py | 6 +++--- testing/python/fixtures.py | 2 +- testing/python/integration.py | 1 + testing/python/metafunc.py | 2 +- testing/python/raises.py | 1 + testing/python/setup_only.py | 1 + testing/python/setup_plan.py | 1 + testing/python/show_fixtures_per_test.py | 2 +- testing/test_argcomplete.py | 1 + testing/test_assertion.py | 4 ++-- testing/test_assertrewrite.py | 8 ++++---- testing/test_cacheprovider.py | 1 + testing/test_capture.py | 4 ++-- testing/test_collection.py | 1 + testing/test_compat.py | 1 + testing/test_config.py | 1 + testing/test_conftest.py | 1 + testing/test_doctest.py | 6 +++--- testing/test_entry_points.py | 1 + testing/test_helpconfig.py | 1 + testing/test_junitxml.py | 2 +- testing/test_mark.py | 1 + testing/test_modimport.py | 1 + testing/test_monkeypatch.py | 1 + testing/test_nodes.py | 1 + testing/test_nose.py | 4 ++-- testing/test_parseopt.py | 1 + testing/test_pastebin.py | 4 ++-- testing/test_pathlib.py | 1 + testing/test_pdb.py | 1 + testing/test_pluginmanager.py | 4 ++-- testing/test_pytester.py | 2 +- testing/test_recwarn.py | 1 + testing/test_reports.py | 1 + testing/test_resultlog.py | 1 + testing/test_runner.py | 6 +++--- testing/test_runner_xunit.py | 1 + testing/test_session.py | 1 + testing/test_skipping.py | 2 +- testing/test_stepwise.py | 1 + testing/test_terminal.py | 2 +- testing/test_tmpdir.py | 1 + testing/test_unittest.py | 1 + testing/test_warnings.py | 8 ++++---- 188 files changed, 206 insertions(+), 45 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c80e42e1..865b7979b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,6 +17,7 @@ repos: hooks: - id: trailing-whitespace - id: end-of-file-fixer + - id: fix-encoding-pragma - id: check-yaml - id: debug-statements exclude: _pytest/debugging.py diff --git a/bench/bench.py b/bench/bench.py index 31cc7ac13..468ef5219 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import sys if __name__ == "__main__": diff --git a/bench/bench_argcomplete.py b/bench/bench_argcomplete.py index 335733df7..297637bad 100644 --- a/bench/bench_argcomplete.py +++ b/bench/bench_argcomplete.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # 10000 iterations, just for relative comparison # 2.7.5 3.3.2 # FilesCompleter 75.1109 69.2116 diff --git a/bench/empty.py b/bench/empty.py index 4e7371b6f..bfda88235 100644 --- a/bench/empty.py +++ b/bench/empty.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- for i in range(1000): exec("def test_func_%d(): pass" % i) diff --git a/bench/manyparam.py b/bench/manyparam.py index 1226c73bd..c47e25f51 100644 --- a/bench/manyparam.py +++ b/bench/manyparam.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/bench/skip.py b/bench/skip.py index 2fc8240e5..29e03e54f 100644 --- a/bench/skip.py +++ b/bench/skip.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from six.moves import range import pytest diff --git a/doc/en/_themes/flask_theme_support.py b/doc/en/_themes/flask_theme_support.py index b107f2c89..c5dcdbe27 100644 --- a/doc/en/_themes/flask_theme_support.py +++ b/doc/en/_themes/flask_theme_support.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # flasky extensions. flasky pygments style based on tango style from pygments.style import Style from pygments.token import Comment diff --git a/doc/en/conftest.py b/doc/en/conftest.py index 1a62e1b5d..b51aae5b6 100644 --- a/doc/en/conftest.py +++ b/doc/en/conftest.py @@ -1 +1,2 @@ +# -*- coding: utf-8 -*- collect_ignore = ["conf.py"] diff --git a/doc/en/example/assertion/failure_demo.py b/doc/en/example/assertion/failure_demo.py index 5d36fa659..ba910ef6a 100644 --- a/doc/en/example/assertion/failure_demo.py +++ b/doc/en/example/assertion/failure_demo.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import _pytest._code import pytest from pytest import raises diff --git a/doc/en/example/assertion/global_testmodule_config/conftest.py b/doc/en/example/assertion/global_testmodule_config/conftest.py index da89047fe..8e04ac2ac 100644 --- a/doc/en/example/assertion/global_testmodule_config/conftest.py +++ b/doc/en/example/assertion/global_testmodule_config/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import py import pytest diff --git a/doc/en/example/assertion/global_testmodule_config/test_hello_world.py b/doc/en/example/assertion/global_testmodule_config/test_hello_world.py index a31a601a1..bfccc94f7 100644 --- a/doc/en/example/assertion/global_testmodule_config/test_hello_world.py +++ b/doc/en/example/assertion/global_testmodule_config/test_hello_world.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- hello = "world" diff --git a/doc/en/example/assertion/test_failures.py b/doc/en/example/assertion/test_failures.py index 30ebc72dc..60b5e2131 100644 --- a/doc/en/example/assertion/test_failures.py +++ b/doc/en/example/assertion/test_failures.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import py failure_demo = py.path.local(__file__).dirpath("failure_demo.py") diff --git a/doc/en/example/assertion/test_setup_flow_example.py b/doc/en/example/assertion/test_setup_flow_example.py index eb339f474..f49d6d8ed 100644 --- a/doc/en/example/assertion/test_setup_flow_example.py +++ b/doc/en/example/assertion/test_setup_flow_example.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- def setup_module(module): module.TestStateFullThing.classcount = 0 diff --git a/doc/en/example/conftest.py b/doc/en/example/conftest.py index f905738c4..1f5a961ad 100644 --- a/doc/en/example/conftest.py +++ b/doc/en/example/conftest.py @@ -1 +1,2 @@ +# -*- coding: utf-8 -*- collect_ignore = ["nonpython"] diff --git a/doc/en/example/costlysetup/conftest.py b/doc/en/example/costlysetup/conftest.py index 57b08b5fa..b90c77473 100644 --- a/doc/en/example/costlysetup/conftest.py +++ b/doc/en/example/costlysetup/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/doc/en/example/costlysetup/sub_a/__init__.py b/doc/en/example/costlysetup/sub_a/__init__.py index 792d60054..ec51c5a2b 100644 --- a/doc/en/example/costlysetup/sub_a/__init__.py +++ b/doc/en/example/costlysetup/sub_a/__init__.py @@ -1 +1,2 @@ +# -*- coding: utf-8 -*- # diff --git a/doc/en/example/costlysetup/sub_a/test_quick.py b/doc/en/example/costlysetup/sub_a/test_quick.py index 38dda2660..4f7b9f1ac 100644 --- a/doc/en/example/costlysetup/sub_a/test_quick.py +++ b/doc/en/example/costlysetup/sub_a/test_quick.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_quick(setup): pass diff --git a/doc/en/example/costlysetup/sub_b/__init__.py b/doc/en/example/costlysetup/sub_b/__init__.py index 792d60054..ec51c5a2b 100644 --- a/doc/en/example/costlysetup/sub_b/__init__.py +++ b/doc/en/example/costlysetup/sub_b/__init__.py @@ -1 +1,2 @@ +# -*- coding: utf-8 -*- # diff --git a/doc/en/example/costlysetup/sub_b/test_two.py b/doc/en/example/costlysetup/sub_b/test_two.py index b1653aaab..4e08bc2b6 100644 --- a/doc/en/example/costlysetup/sub_b/test_two.py +++ b/doc/en/example/costlysetup/sub_b/test_two.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- def test_something(setup): assert setup.timecostly == 1 diff --git a/doc/en/example/multipython.py b/doc/en/example/multipython.py index 4151c50a0..dc722aac9 100644 --- a/doc/en/example/multipython.py +++ b/doc/en/example/multipython.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ module containing a parametrized tests testing cross-python serialization via the pickle module. diff --git a/doc/en/example/nonpython/conftest.py b/doc/en/example/nonpython/conftest.py index 7c23025af..306aa2503 100644 --- a/doc/en/example/nonpython/conftest.py +++ b/doc/en/example/nonpython/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # content of conftest.py import pytest diff --git a/doc/en/example/py2py3/conftest.py b/doc/en/example/py2py3/conftest.py index 844510a25..a6b9af7a8 100644 --- a/doc/en/example/py2py3/conftest.py +++ b/doc/en/example/py2py3/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import sys import pytest diff --git a/doc/en/example/py2py3/test_py3.py b/doc/en/example/py2py3/test_py3.py index d95702a53..30151f914 100644 --- a/doc/en/example/py2py3/test_py3.py +++ b/doc/en/example/py2py3/test_py3.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- def test_exception_syntax(): try: 0 / 0 diff --git a/doc/en/example/pythoncollection.py b/doc/en/example/pythoncollection.py index b134d809d..bbc3fe868 100644 --- a/doc/en/example/pythoncollection.py +++ b/doc/en/example/pythoncollection.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # run this with $ pytest --collect-only test_collectonly.py # diff --git a/doc/en/example/xfail_demo.py b/doc/en/example/xfail_demo.py index 01e6da1ad..88384a156 100644 --- a/doc/en/example/xfail_demo.py +++ b/doc/en/example/xfail_demo.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest xfail = pytest.mark.xfail diff --git a/extra/get_issues.py b/extra/get_issues.py index 9407aeded..598a1af40 100644 --- a/extra/get_issues.py +++ b/extra/get_issues.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import json import py diff --git a/extra/setup-py.test/setup.py b/extra/setup-py.test/setup.py index d0560ce1f..cfe18c28f 100644 --- a/extra/setup-py.test/setup.py +++ b/extra/setup-py.test/setup.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import sys from distutils.core import setup diff --git a/scripts/release.py b/scripts/release.py index 5009df359..32178fcf6 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Invoke development tasks. """ diff --git a/setup.py b/setup.py index 0fb5a58a2..c16504411 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from setuptools import setup # TODO: if py gets upgrade to >=1.6, diff --git a/src/_pytest/__init__.py b/src/_pytest/__init__.py index 46c7827ed..17cc20b61 100644 --- a/src/_pytest/__init__.py +++ b/src/_pytest/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- __all__ = ["__version__"] try: diff --git a/src/_pytest/_argcomplete.py b/src/_pytest/_argcomplete.py index 455c3a7be..c6cf1d8fd 100644 --- a/src/_pytest/_argcomplete.py +++ b/src/_pytest/_argcomplete.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """allow bash-completion for argparse with argcomplete if installed needs argcomplete>=0.5.6 for python 3.2/3.3 (older versions fail to find the magic string, so _ARGCOMPLETE env. var is never set, and diff --git a/src/_pytest/_code/__init__.py b/src/_pytest/_code/__init__.py index fe755a399..1394b2b10 100644 --- a/src/_pytest/_code/__init__.py +++ b/src/_pytest/_code/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ python inspection/code generation API """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/_code/_py2traceback.py b/src/_pytest/_code/_py2traceback.py index 8a8b7bc00..faacc0216 100644 --- a/src/_pytest/_code/_py2traceback.py +++ b/src/_pytest/_code/_py2traceback.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # copied from python-2.7.3's traceback.py # CHANGES: # - some_str is replaced, trying to create unicode strings diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index a0b3c78ce..5f8110428 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py index 39701a39b..c8a4b6adf 100644 --- a/src/_pytest/_code/source.py +++ b/src/_pytest/_code/source.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/src/_pytest/_io/saferepr.py b/src/_pytest/_io/saferepr.py index d817e3745..9b412dcca 100644 --- a/src/_pytest/_io/saferepr.py +++ b/src/_pytest/_io/saferepr.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pprint from six.moves import reprlib diff --git a/src/_pytest/assertion/__init__.py b/src/_pytest/assertion/__init__.py index b5c846c2c..6b6abb863 100644 --- a/src/_pytest/assertion/__init__.py +++ b/src/_pytest/assertion/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ support for presenting detailed information in failing assertions. """ diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 2903b8995..68d41c4b9 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """Rewrite assertion AST to produce nice error messages""" from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/assertion/truncate.py b/src/_pytest/assertion/truncate.py index 69d6acdef..525896ea9 100644 --- a/src/_pytest/assertion/truncate.py +++ b/src/_pytest/assertion/truncate.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Utilities for truncating assertion output. diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index b53646859..1fee64ce0 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """Utilities for assertion debugging""" from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index aa4813c3f..3eaf7de28 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ merged implementation of the cache provider diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 25eab7fdf..80f9c0442 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ per-test stdout/stderr capturing mechanism. diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index fa878a485..19863dd83 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ python version compatibility code """ diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 03769b815..f2ef45c29 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ command line options, ini-file and conftest.py processing. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index cc48ed337..37fb772db 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import argparse import warnings diff --git a/src/_pytest/config/exceptions.py b/src/_pytest/config/exceptions.py index 19fe5cb08..bf58fde5d 100644 --- a/src/_pytest/config/exceptions.py +++ b/src/_pytest/config/exceptions.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- class UsageError(Exception): """ error in pytest usage or invocation""" diff --git a/src/_pytest/config/findpaths.py b/src/_pytest/config/findpaths.py index fa2024470..3ece3bdc1 100644 --- a/src/_pytest/config/findpaths.py +++ b/src/_pytest/config/findpaths.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import os import py diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 52c6536f4..139645b17 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ interactive debugging with PDB, the Python Debugger. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index b65700417..6283a8402 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ This module contains deprecation messages and bits of code used elsewhere in the codebase that is planned to be removed in the next pytest release. diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 34b6c9d8c..95a80bb4f 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ discover and run doctests in modules and test files.""" from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 902904457..ad2d376f1 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/src/_pytest/freeze_support.py b/src/_pytest/freeze_support.py index 5edf3454c..aeeec2a56 100644 --- a/src/_pytest/freeze_support.py +++ b/src/_pytest/freeze_support.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Provides a function to report all internal modules for using freezing tools pytest diff --git a/src/_pytest/helpconfig.py b/src/_pytest/helpconfig.py index 2b383d264..fb4371d0e 100644 --- a/src/_pytest/helpconfig.py +++ b/src/_pytest/helpconfig.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ version info, help messages, tracing configuration. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index d40a36811..7ab6154b1 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ hook specifications for pytest plugins, invoked from main.py and builtin plugins. """ from pluggy import HookspecMarker diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index e3c98c37e..b58d8fab0 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ report test results in JUnit-XML format, for use with Jenkins and build integration servers. diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 08670d2b2..660912c91 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Access and control log capturing. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 96ead8509..fa4d8d3d5 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ core implementation of testing process: init, session, runtest loop. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index e98dc5c37..6bc22fe27 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ generic mechanism for marking and selecting python functions. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/mark/evaluate.py b/src/_pytest/mark/evaluate.py index 793bff79e..506546e25 100644 --- a/src/_pytest/mark/evaluate.py +++ b/src/_pytest/mark/evaluate.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import os import platform import sys diff --git a/src/_pytest/mark/legacy.py b/src/_pytest/mark/legacy.py index f784ffa20..c56482f14 100644 --- a/src/_pytest/mark/legacy.py +++ b/src/_pytest/mark/legacy.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ this is a place where we put datastructures used by legacy apis we hope ot remove diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index a734ae1d4..b133a4e26 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import inspect import warnings from collections import namedtuple diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index 3e221d3d9..e8671b0c7 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ monkeypatching and mocking functionality. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 4dd0e1785..7342d9607 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/src/_pytest/nose.py b/src/_pytest/nose.py index 492388260..fbab91da2 100644 --- a/src/_pytest/nose.py +++ b/src/_pytest/nose.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ run test suites written for nose. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index f57983918..48e2b7367 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ exception classes and constants handling test outcomes as well as functions creating them diff --git a/src/_pytest/pastebin.py b/src/_pytest/pastebin.py index 9559e3265..3f4171207 100644 --- a/src/_pytest/pastebin.py +++ b/src/_pytest/pastebin.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ submit failure or test session information to a pastebin service. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 5dd00e74f..729c41797 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import atexit import errno import fnmatch diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 413b21824..21f5b9f24 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """(disabled by default) support for testing pytest and pytest plugins.""" from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 18d909855..f55617e2d 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Python test discovery, setup and run of test functions. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 7e7570008..e2fcdfc28 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import import math diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 394d91911..574c6a1cc 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ recording warnings during test function execution. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 43d7e54a4..0bba6762c 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pprint import pprint import py diff --git a/src/_pytest/resultlog.py b/src/_pytest/resultlog.py index cd3fde80f..bd30b5071 100644 --- a/src/_pytest/resultlog.py +++ b/src/_pytest/resultlog.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ log machine-parseable test session result information in a plain text file. """ diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 7fb343d4e..d51e859f1 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ basic collect and runtest protocol implementations """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/setuponly.py b/src/_pytest/setuponly.py index 4bd4ad6d8..085901124 100644 --- a/src/_pytest/setuponly.py +++ b/src/_pytest/setuponly.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/src/_pytest/setupplan.py b/src/_pytest/setupplan.py index 351e0be65..47b0fe82e 100644 --- a/src/_pytest/setupplan.py +++ b/src/_pytest/setupplan.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 94a43de49..bc8b88e71 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- """ support for skip/xfail functions and markers. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index 68e53a31c..0427cd0ea 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 771e6a835..81e3f1809 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- coding: utf-8 -*- """ terminal reporting of the full testing process. This is a good source for looking at the various reporting hooks. diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 4d109cc2b..f1b16fb5c 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ support for providing temporary directories to test functions. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index 58d79845b..e2e7efdc5 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ discovery and running of std-library "unittest" style tests. """ from __future__ import absolute_import from __future__ import division diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index 2777aabea..861010a12 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import attr diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py index 3360aea9c..a3debae46 100644 --- a/src/_pytest/warnings.py +++ b/src/_pytest/warnings.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/src/pytest.py b/src/pytest.py index a6376843d..ccc77b476 100644 --- a/src/pytest.py +++ b/src/pytest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # PYTHON_ARGCOMPLETE_OK """ pytest: unit and functional testing with Python. diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index a6bf93459..b0c682900 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/code/test_code.py b/testing/code/test_code.py index 81a87481c..0b63fcf4d 100644 --- a/testing/code/test_code.py +++ b/testing/code/test_code.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 09e96a45f..a76797301 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 7a9e8b79f..0a2a98c02 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- # flake8: noqa # disable flake check on this file because some constructs are strange # or redundant on purpose and can't be disable on a line-by-line basis diff --git a/testing/conftest.py b/testing/conftest.py index 4582c7d90..ecc945279 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index 4818379fe..a072f6b21 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/example_scripts/acceptance/fixture_mock_integration.py b/testing/example_scripts/acceptance/fixture_mock_integration.py index c005c9193..c8ccdf1b4 100644 --- a/testing/example_scripts/acceptance/fixture_mock_integration.py +++ b/testing/example_scripts/acceptance/fixture_mock_integration.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """Reproduces issue #3774""" try: diff --git a/testing/example_scripts/collect/collect_init_tests/tests/__init__.py b/testing/example_scripts/collect/collect_init_tests/tests/__init__.py index 9cd366295..621105571 100644 --- a/testing/example_scripts/collect/collect_init_tests/tests/__init__.py +++ b/testing/example_scripts/collect/collect_init_tests/tests/__init__.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_init(): pass diff --git a/testing/example_scripts/collect/collect_init_tests/tests/test_foo.py b/testing/example_scripts/collect/collect_init_tests/tests/test_foo.py index 8f2d73cfa..8c560fd13 100644 --- a/testing/example_scripts/collect/collect_init_tests/tests/test_foo.py +++ b/testing/example_scripts/collect/collect_init_tests/tests/test_foo.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_foo(): pass diff --git a/testing/example_scripts/collect/package_infinite_recursion/conftest.py b/testing/example_scripts/collect/package_infinite_recursion/conftest.py index 9629fa646..9c3d9a791 100644 --- a/testing/example_scripts/collect/package_infinite_recursion/conftest.py +++ b/testing/example_scripts/collect/package_infinite_recursion/conftest.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def pytest_ignore_collect(path): return False diff --git a/testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py b/testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py index f17482385..10c5f6052 100644 --- a/testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py +++ b/testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test(): pass diff --git a/testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py b/testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py index f17482385..10c5f6052 100644 --- a/testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py +++ b/testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test(): pass diff --git a/testing/example_scripts/config/collect_pytest_prefix/conftest.py b/testing/example_scripts/config/collect_pytest_prefix/conftest.py index 56a4c71d3..13397ccc4 100644 --- a/testing/example_scripts/config/collect_pytest_prefix/conftest.py +++ b/testing/example_scripts/config/collect_pytest_prefix/conftest.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- class pytest_something(object): pass diff --git a/testing/example_scripts/config/collect_pytest_prefix/test_foo.py b/testing/example_scripts/config/collect_pytest_prefix/test_foo.py index 8f2d73cfa..8c560fd13 100644 --- a/testing/example_scripts/config/collect_pytest_prefix/test_foo.py +++ b/testing/example_scripts/config/collect_pytest_prefix/test_foo.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_foo(): pass diff --git a/testing/example_scripts/conftest_usageerror/conftest.py b/testing/example_scripts/conftest_usageerror/conftest.py index 8973e4252..d2f040578 100644 --- a/testing/example_scripts/conftest_usageerror/conftest.py +++ b/testing/example_scripts/conftest_usageerror/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- def pytest_configure(config): import pytest diff --git a/testing/example_scripts/dataclasses/test_compare_dataclasses.py b/testing/example_scripts/dataclasses/test_compare_dataclasses.py index 3bbebe2aa..5381b5ed0 100644 --- a/testing/example_scripts/dataclasses/test_compare_dataclasses.py +++ b/testing/example_scripts/dataclasses/test_compare_dataclasses.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from dataclasses import dataclass from dataclasses import field diff --git a/testing/example_scripts/dataclasses/test_compare_dataclasses_field_comparison_off.py b/testing/example_scripts/dataclasses/test_compare_dataclasses_field_comparison_off.py index 63b9f534e..d418dd6b0 100644 --- a/testing/example_scripts/dataclasses/test_compare_dataclasses_field_comparison_off.py +++ b/testing/example_scripts/dataclasses/test_compare_dataclasses_field_comparison_off.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from dataclasses import dataclass from dataclasses import field diff --git a/testing/example_scripts/dataclasses/test_compare_dataclasses_verbose.py b/testing/example_scripts/dataclasses/test_compare_dataclasses_verbose.py index 17835c0c3..a72ca5119 100644 --- a/testing/example_scripts/dataclasses/test_compare_dataclasses_verbose.py +++ b/testing/example_scripts/dataclasses/test_compare_dataclasses_verbose.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from dataclasses import dataclass from dataclasses import field diff --git a/testing/example_scripts/dataclasses/test_compare_two_different_dataclasses.py b/testing/example_scripts/dataclasses/test_compare_two_different_dataclasses.py index 24f185d8a..b77b70d3c 100644 --- a/testing/example_scripts/dataclasses/test_compare_two_different_dataclasses.py +++ b/testing/example_scripts/dataclasses/test_compare_two_different_dataclasses.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from dataclasses import dataclass from dataclasses import field diff --git a/testing/example_scripts/deprecated/test_fixture_named_request.py b/testing/example_scripts/deprecated/test_fixture_named_request.py index 75514bf8b..36addc299 100644 --- a/testing/example_scripts/deprecated/test_fixture_named_request.py +++ b/testing/example_scripts/deprecated/test_fixture_named_request.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/custom_item/conftest.py b/testing/example_scripts/fixtures/custom_item/conftest.py index 25299d726..fa41d0fba 100644 --- a/testing/example_scripts/fixtures/custom_item/conftest.py +++ b/testing/example_scripts/fixtures/custom_item/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/custom_item/foo/test_foo.py b/testing/example_scripts/fixtures/custom_item/foo/test_foo.py index f17482385..10c5f6052 100644 --- a/testing/example_scripts/fixtures/custom_item/foo/test_foo.py +++ b/testing/example_scripts/fixtures/custom_item/foo/test_foo.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test(): pass diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py index 79af4bc47..952e7d60a 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py index df36da136..b824f4e99 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_1(arg1): pass diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py index 00981c5dc..2be90b4df 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py index 1c34f94ac..a1432042b 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_2(arg2): pass diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py b/testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py index d1efcbb33..d1e54eea7 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py index 5dfd2f779..87756e649 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py index 4e22ce5a1..1cd88524b 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py index 0d891fbb5..65690c49f 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_spam(spam): assert spam == "spamspam" diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py index 5dfd2f779..87756e649 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py index 46d1446f4..5b344c122 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py index 2b8218ed7..4332c6601 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py index 0661cb301..ba302c49e 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py index 7b7183dd9..1004d5d13 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py index 227abb593..79d283e9f 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py index b77520323..18f426af9 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py b/testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py index 055a1220b..219e57421 100644 --- a/testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py +++ b/testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/issue88_initial_file_multinodes/conftest.py b/testing/example_scripts/issue88_initial_file_multinodes/conftest.py index aa5d87831..8f3e7b4e5 100644 --- a/testing/example_scripts/issue88_initial_file_multinodes/conftest.py +++ b/testing/example_scripts/issue88_initial_file_multinodes/conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/issue88_initial_file_multinodes/test_hello.py b/testing/example_scripts/issue88_initial_file_multinodes/test_hello.py index 56444d147..653d570a8 100644 --- a/testing/example_scripts/issue88_initial_file_multinodes/test_hello.py +++ b/testing/example_scripts/issue88_initial_file_multinodes/test_hello.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_hello(): pass diff --git a/testing/example_scripts/issue_519.py b/testing/example_scripts/issue_519.py index 7199df820..24d864a53 100644 --- a/testing/example_scripts/issue_519.py +++ b/testing/example_scripts/issue_519.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pprint import pytest diff --git a/testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py b/testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py index 35a2c7b76..61d969a36 100644 --- a/testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py +++ b/testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/perf_examples/collect_stats/generate_folders.py b/testing/example_scripts/perf_examples/collect_stats/generate_folders.py index ff1eaf7d6..32ca818ea 100644 --- a/testing/example_scripts/perf_examples/collect_stats/generate_folders.py +++ b/testing/example_scripts/perf_examples/collect_stats/generate_folders.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import argparse import pathlib diff --git a/testing/example_scripts/perf_examples/collect_stats/template_test.py b/testing/example_scripts/perf_examples/collect_stats/template_test.py index 064ade190..5d0cd5a71 100644 --- a/testing/example_scripts/perf_examples/collect_stats/template_test.py +++ b/testing/example_scripts/perf_examples/collect_stats/template_test.py @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- def test_x(): pass diff --git a/testing/example_scripts/tmpdir/tmpdir_fixture.py b/testing/example_scripts/tmpdir/tmpdir_fixture.py index f4ad07462..33f0315d5 100644 --- a/testing/example_scripts/tmpdir/tmpdir_fixture.py +++ b/testing/example_scripts/tmpdir/tmpdir_fixture.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py b/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py index d421ce927..cef950ee7 100644 --- a/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py +++ b/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import unittest import pytest diff --git a/testing/example_scripts/unittest/test_setup_skip.py b/testing/example_scripts/unittest/test_setup_skip.py index 93f79bb3b..26b6195e9 100644 --- a/testing/example_scripts/unittest/test_setup_skip.py +++ b/testing/example_scripts/unittest/test_setup_skip.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """Skipping an entire subclass with unittest.skip() should *not* call setUp from a base class.""" import unittest diff --git a/testing/example_scripts/unittest/test_setup_skip_class.py b/testing/example_scripts/unittest/test_setup_skip_class.py index 4f251dcba..0c4a37757 100644 --- a/testing/example_scripts/unittest/test_setup_skip_class.py +++ b/testing/example_scripts/unittest/test_setup_skip_class.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """Skipping an entire subclass with unittest.skip() should *not* call setUpClass from a base class.""" import unittest diff --git a/testing/example_scripts/unittest/test_setup_skip_module.py b/testing/example_scripts/unittest/test_setup_skip_module.py index 98befbe51..abf782a62 100644 --- a/testing/example_scripts/unittest/test_setup_skip_module.py +++ b/testing/example_scripts/unittest/test_setup_skip_module.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """setUpModule is always called, even if all tests in the module are skipped""" import unittest diff --git a/testing/example_scripts/warnings/test_group_warnings_by_message.py b/testing/example_scripts/warnings/test_group_warnings_by_message.py index c736135b7..29d895974 100644 --- a/testing/example_scripts/warnings/test_group_warnings_by_message.py +++ b/testing/example_scripts/warnings/test_group_warnings_by_message.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import warnings import pytest diff --git a/testing/examples/test_issue519.py b/testing/examples/test_issue519.py index e83f18fdc..7da1f4ee6 100644 --- a/testing/examples/test_issue519.py +++ b/testing/examples/test_issue519.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- def test_510(testdir): testdir.copy_example("issue_519.py") testdir.runpytest("issue_519.py") diff --git a/testing/freeze/create_executable.py b/testing/freeze/create_executable.py index b53eb09f5..ab8013317 100644 --- a/testing/freeze/create_executable.py +++ b/testing/freeze/create_executable.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Generates an executable with pytest runner embedded using PyInstaller. """ diff --git a/testing/freeze/runtests_script.py b/testing/freeze/runtests_script.py index d03bca840..f7381f568 100644 --- a/testing/freeze/runtests_script.py +++ b/testing/freeze/runtests_script.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ This is the script that is actually frozen into an executable: simply executes py.test main(). diff --git a/testing/freeze/tests/test_trivial.py b/testing/freeze/tests/test_trivial.py index 08a55552a..449dbf9d3 100644 --- a/testing/freeze/tests/test_trivial.py +++ b/testing/freeze/tests/test_trivial.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- def test_upper(): assert "foo".upper() == "FOO" diff --git a/testing/freeze/tox_run.py b/testing/freeze/tox_run.py index 678a69c85..29b727923 100644 --- a/testing/freeze/tox_run.py +++ b/testing/freeze/tox_run.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Called by tox.ini: uses the generated executable to run the tests in ./tests/ directory. diff --git a/testing/io/test_saferepr.py b/testing/io/test_saferepr.py index abee94999..901203088 100644 --- a/testing/io/test_saferepr.py +++ b/testing/io/test_saferepr.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from _pytest._io.saferepr import saferepr diff --git a/testing/logging/test_fixture.py b/testing/logging/test_fixture.py index 89065b086..ff772e7ec 100644 --- a/testing/logging/test_fixture.py +++ b/testing/logging/test_fixture.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- import logging import pytest diff --git a/testing/logging/test_formatter.py b/testing/logging/test_formatter.py index abceaf857..1610da845 100644 --- a/testing/logging/test_formatter.py +++ b/testing/logging/test_formatter.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import logging import py.io diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index ce6892492..77cf71b43 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- import os import re from io import open @@ -842,7 +842,7 @@ def test_log_file_unicode(testdir): ) testdir.makepyfile( """ - # coding: utf-8 + # -*- coding: utf-8 -*- from __future__ import unicode_literals import logging diff --git a/testing/python/approx.py b/testing/python/approx.py index 26e6a4ab2..cd8df5d27 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- coding: utf-8 -*- import doctest import operator import sys diff --git a/testing/python/collect.py b/testing/python/collect.py index 3b5e9dd42..bfd7e672e 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- import os import sys import textwrap @@ -119,7 +119,7 @@ class TestModule(object): """ testdir.makepyfile( u""" - # coding: utf-8 + # -*- coding: utf-8 -*- raise ImportError(u'Something bad happened ☺') """ ) @@ -1244,7 +1244,7 @@ def test_syntax_error_with_non_ascii_chars(testdir): """ testdir.makepyfile( u""" - # coding: utf-8 + # -*- coding: utf-8 -*- ☃ """ diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 2f64b1be2..18ede4006 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- import sys import textwrap diff --git a/testing/python/integration.py b/testing/python/integration.py index a62747014..d2fea2dc5 100644 --- a/testing/python/integration.py +++ b/testing/python/integration.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from _pytest import python from _pytest import runner diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 2a84a7a57..29f18da36 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- import re import sys import textwrap diff --git a/testing/python/raises.py b/testing/python/raises.py index f5827e9b0..cd463d74b 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import sys import six diff --git a/testing/python/setup_only.py b/testing/python/setup_only.py index 4ae24b15a..ba4ceb00f 100644 --- a/testing/python/setup_only.py +++ b/testing/python/setup_only.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/python/setup_plan.py b/testing/python/setup_plan.py index 0321939a8..ad64e42c2 100644 --- a/testing/python/setup_plan.py +++ b/testing/python/setup_plan.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- def test_show_fixtures_and_test(testdir): """ Verifies that fixtures are not executed. """ p = testdir.makepyfile( diff --git a/testing/python/show_fixtures_per_test.py b/testing/python/show_fixtures_per_test.py index f677b3067..e14344d4e 100644 --- a/testing/python/show_fixtures_per_test.py +++ b/testing/python/show_fixtures_per_test.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- def test_no_items_should_not_show_output(testdir): diff --git a/testing/test_argcomplete.py b/testing/test_argcomplete.py index 046d69aa0..da7758e8e 100644 --- a/testing/test_argcomplete.py +++ b/testing/test_argcomplete.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 7d92b1bac..8a59b7e8d 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -1297,7 +1297,7 @@ def test_assert_indirect_tuple_no_warning(testdir): def test_assert_with_unicode(monkeypatch, testdir): testdir.makepyfile( u""" - # coding: utf-8 + # -*- coding: utf-8 -*- def test_unicode(): assert u'유니코드' == u'Unicode' """ diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 5b527ca22..87dada213 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -960,7 +960,7 @@ class TestAssertionRewriteHookDetails(object): def test_detect_coding_cookie(self, testdir): testdir.makepyfile( test_cookie=""" - # coding: utf-8 + # -*- coding: utf-8 -*- u"St\xc3\xa4d" def test_rewritten(): assert "@py_builtins" in globals()""" @@ -971,7 +971,7 @@ class TestAssertionRewriteHookDetails(object): def test_detect_coding_cookie_second_line(self, testdir): testdir.makepyfile( test_cookie=""" - # coding: utf-8 + # -*- coding: utf-8 -*- u"St\xc3\xa4d" def test_rewritten(): assert "@py_builtins" in globals()""" @@ -982,7 +982,7 @@ class TestAssertionRewriteHookDetails(object): def test_detect_coding_cookie_crlf(self, testdir): testdir.makepyfile( test_cookie=""" - # coding: utf-8 + # -*- coding: utf-8 -*- u"St\xc3\xa4d" def test_rewritten(): assert "@py_builtins" in globals()""" diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 02c758424..5024701f1 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_capture.py b/testing/test_capture.py index 42bb4b8aa..7f757c6d6 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -106,7 +106,7 @@ def test_capturing_unicode(testdir, method): obj = "u'\u00f6y'" testdir.makepyfile( """ - # coding: utf-8 + # -*- coding: utf-8 -*- # taken from issue 227 from nosetests def test_unicode(): import sys diff --git a/testing/test_collection.py b/testing/test_collection.py index 5aaaddbea..1cc893866 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_compat.py b/testing/test_compat.py index 6c4d24398..b4298d153 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_config.py b/testing/test_config.py index ecb8fd403..325f4858e 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_conftest.py b/testing/test_conftest.py index acb9b52b4..f8e3dfa92 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_doctest.py b/testing/test_doctest.py index 164fdc423..25a35c3c1 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -581,7 +581,7 @@ class TestDoctests(object): """ testdir.makepyfile( u''' - # encoding: utf-8 + # -*- coding: utf-8 -*- def foo(): """ >>> name = 'с' # not letter 'c' but instead Cyrillic 's'. @@ -658,7 +658,7 @@ class TestDoctests(object): """ p = testdir.makepyfile( test_unicode_doctest_module=""" - # encoding: utf-8 + # -*- coding: utf-8 -*- from __future__ import unicode_literals def fix_bad_unicode(text): diff --git a/testing/test_entry_points.py b/testing/test_entry_points.py index dcb9dd525..af1db04bc 100644 --- a/testing/test_entry_points.py +++ b/testing/test_entry_points.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_helpconfig.py b/testing/test_helpconfig.py index 9c7806d54..75888fe14 100644 --- a/testing/test_helpconfig.py +++ b/testing/test_helpconfig.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 41b27e275..cca0143a2 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_mark.py b/testing/test_mark.py index b2f893438..5bd97d547 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_modimport.py b/testing/test_modimport.py index 3d7a07323..5dd057c55 100644 --- a/testing/test_modimport.py +++ b/testing/test_modimport.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import subprocess import sys diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 9e45e05c8..9b2f45502 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_nodes.py b/testing/test_nodes.py index b13ce1fe6..e86bd5f79 100644 --- a/testing/test_nodes.py +++ b/testing/test_nodes.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import py import pytest diff --git a/testing/test_nose.py b/testing/test_nose.py index 2fe49177a..6eb5f085e 100644 --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -372,7 +372,7 @@ def test_nottest_class_decorator(testdir): def test_skip_test_with_unicode(testdir): testdir.makepyfile( """ - # encoding: utf-8 + # -*- coding: utf-8 -*- import unittest class TestClass(): def test_io(self): diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index 91f9a7d2b..c570ed60b 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_pastebin.py b/testing/test_pastebin.py index 04f316e52..9491f6d90 100644 --- a/testing/test_pastebin.py +++ b/testing/test_pastebin.py @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -68,7 +68,7 @@ class TestPasteCapture(object): """ testdir.makepyfile( test_unicode=""" - # encoding: utf-8 + # -*- coding: utf-8 -*- def test(): assert '☺' == 1 """ diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index 8ac404070..541d289f7 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import sys import py diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 3b21bacd9..ed38a6133 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 423a20c29..236551643 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -155,7 +155,7 @@ def test_importplugin_error_message(testdir, pytestpm): testdir.syspathinsert(testdir.tmpdir) testdir.makepyfile( qwe=""" - # encoding: utf-8 + # -*- coding: utf-8 -*- def test_traceback(): raise ImportError(u'Not possible to import: ☺') test_traceback() diff --git a/testing/test_pytester.py b/testing/test_pytester.py index bf6e5d97e..b76d413b7 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index 982e246d7..2246085f5 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_reports.py b/testing/test_reports.py index 6d2b167f8..5c6851e49 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest from _pytest.pathlib import Path from _pytest.reports import CollectReport diff --git a/testing/test_resultlog.py b/testing/test_resultlog.py index aba5713af..1ef49d5e2 100644 --- a/testing/test_resultlog.py +++ b/testing/test_resultlog.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_runner.py b/testing/test_runner.py index 7ab63b346..6906efb91 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -645,7 +645,7 @@ def test_pytest_fail_notrace_non_ascii(testdir, str_prefix): """ testdir.makepyfile( u""" - # coding: utf-8 + # -*- coding: utf-8 -*- import pytest def test_hello(): @@ -793,7 +793,7 @@ def test_pytest_cmdline_main(testdir): def test_unicode_in_longrepr(testdir): testdir.makeconftest( """ - # coding: utf-8 + # -*- coding: utf-8 -*- import pytest @pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(): diff --git a/testing/test_runner_xunit.py b/testing/test_runner_xunit.py index 6b5752b77..5be7297f6 100644 --- a/testing/test_runner_xunit.py +++ b/testing/test_runner_xunit.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ test correct setup/teardowns at module, class, and instance level diff --git a/testing/test_session.py b/testing/test_session.py index 377b28937..c4b0eea79 100644 --- a/testing/test_session.py +++ b/testing/test_session.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 8df726bc8..38273073d 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py index 2202bbf1b..68e5989ec 100644 --- a/testing/test_stepwise.py +++ b/testing/test_stepwise.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import pytest diff --git a/testing/test_terminal.py b/testing/test_terminal.py index f269fccd2..fef73c4a9 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1,4 +1,4 @@ -# encoding: utf-8 +# -*- coding: utf-8 -*- """ terminal reporting of the full testing process. """ diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index c49f7930d..40ffe98af 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 78250dae3..bb41952ab 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function diff --git a/testing/test_warnings.py b/testing/test_warnings.py index ce157cbed..092604d7d 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- from __future__ import unicode_literals import sys @@ -133,7 +133,7 @@ def test_ignore(testdir, pyfile_with_warnings, method): def test_unicode(testdir, pyfile_with_warnings): testdir.makepyfile( """ - # coding: utf-8 + # -*- coding: utf-8 -*- import warnings import pytest @@ -168,7 +168,7 @@ def test_py2_unicode(testdir, pyfile_with_warnings): pytest.xfail("fails with unicode error on PyPy2 5.9 and Windows (#2905)") testdir.makepyfile( """ - # coding: utf-8 + # -*- coding: utf-8 -*- import warnings import pytest @@ -577,7 +577,7 @@ def test_infinite_loop_warning_against_unicode_usage_py2(testdir): """ testdir.makepyfile( """ - # coding: utf-8 + # -*- coding: utf-8 -*- from __future__ import unicode_literals import warnings import pytest From b81173ea0c4462509430e361942118054090b443 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 15 May 2019 10:19:12 -0700 Subject: [PATCH 04/22] Upgrade pre-commit/pre-commit-hooks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 865b7979b..34895e1a3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: additional_dependencies: [black==19.3b0] language_version: python3 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.1.0 + rev: v2.2.2 hooks: - id: trailing-whitespace - id: end-of-file-fixer From 93fd9debe34bbd6dedfa52d3ffc631c201b23b6e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 16 May 2019 16:30:40 +0200 Subject: [PATCH 05/22] Allow disabling of python plugin Fixes https://github.com/pytest-dev/pytest/issues/5277. --- src/_pytest/assertion/rewrite.py | 5 ++++- src/_pytest/config/__init__.py | 6 +++--- src/_pytest/fixtures.py | 9 +++++++++ src/_pytest/python.py | 7 +------ testing/test_config.py | 11 +++++++++++ 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 2903b8995..9f87f5539 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -60,7 +60,10 @@ class AssertionRewritingHook(object): def __init__(self, config): self.config = config - self.fnpats = config.getini("python_files") + try: + self.fnpats = config.getini("python_files") + except ValueError: + self.fnpats = ["test_*.py", "*_test.py"] self.session = None self.modules = {} self._rewritten_names = set() diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 03769b815..e630b199c 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -113,16 +113,16 @@ def directory_arg(path, optname): # Plugins that cannot be disabled via "-p no:X" currently. -essential_plugins = ( +essential_plugins = ( # fmt: off "mark", "main", "runner", - "python", "fixtures", "helpconfig", # Provides -p. -) +) # fmt: on default_plugins = essential_plugins + ( + "python", "terminal", "debugging", "unittest", diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 902904457..0a6e04600 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1075,6 +1075,15 @@ def pytestconfig(request): return request.config +def pytest_addoption(parser): + parser.addini( + "usefixtures", + type="args", + default=[], + help="list of default fixtures to be used with this project", + ) + + class FixtureManager(object): """ pytest fixtures definitions and information is stored and managed diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 18d909855..a6edff0af 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -79,15 +79,10 @@ def pytest_addoption(parser): default=False, help="show fixtures per test", ) - parser.addini( - "usefixtures", - type="args", - default=[], - help="list of default fixtures to be used with this project", - ) parser.addini( "python_files", type="args", + # NOTE: default is also used in AssertionRewritingHook. default=["test_*.py", "*_test.py"], help="glob-style file patterns for Python test module discovery", ) diff --git a/testing/test_config.py b/testing/test_config.py index ecb8fd403..cee3c6403 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1228,6 +1228,17 @@ def test_config_blocked_default_plugins(testdir, plugin): p = testdir.makepyfile("def test(): pass") result = testdir.runpytest(str(p), "-pno:%s" % plugin) + + if plugin == "python": + assert result.ret == EXIT_USAGEERROR + result.stderr.fnmatch_lines( + [ + "ERROR: not found: */test_config_blocked_default_plugins.py", + "(no name '*/test_config_blocked_default_plugins.py' in any of [])", + ] + ) + return + assert result.ret == EXIT_OK if plugin != "terminal": result.stdout.fnmatch_lines(["* 1 passed in *"]) From 8f04bd003c67e6b1bffb2175fe191cc33954a95b Mon Sep 17 00:00:00 2001 From: MyComputer Date: Sat, 18 May 2019 17:11:23 -0400 Subject: [PATCH 06/22] Fix misspellings --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 013e891d8..86a2d9b84 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1630,7 +1630,7 @@ Bug Fixes - `#2220 `_: Fix a bug where fixtures overridden by direct parameters (for example parametrization) were being instantiated even if they were not being used by a test. -- `#3695 `_: Fix ``ApproxNumpy`` initialisation argument mixup, ``abs`` and ``rel`` tolerances were flipped causing strange comparsion results. +- `#3695 `_: Fix ``ApproxNumpy`` initialisation argument mixup, ``abs`` and ``rel`` tolerances were flipped causing strange comparison results. Add tests to check ``abs`` and ``rel`` tolerances for ``np.array`` and test for expecting ``nan`` with ``np.array()`` From b27e40cbf1f01b8bf92ecfc996ee89b22f0c9692 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 19 May 2019 15:56:19 +0200 Subject: [PATCH 07/22] Fix documentation of pytest.raises(match=...) --- src/_pytest/_code/code.py | 9 +++++---- src/_pytest/python_api.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index a0b3c78ce..238778c06 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -564,10 +564,11 @@ class ExceptionInfo(object): def match(self, regexp): """ - Match the regular expression 'regexp' on the string representation of - the exception. If it matches then True is returned (so that it is - possible to write 'assert excinfo.match()'). If it doesn't match an - AssertionError is raised. + Check whether the regular expression 'regexp' is found in the string + representation of the exception using ``re.search``. If it matches + then True is returned (so that it is possible to write + ``assert excinfo.match()``). If it doesn't match an AssertionError is + raised. """ __tracebackhide__ = True if not re.search(regexp, str(self.value)): diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 7e7570008..9bdec3a33 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -559,7 +559,7 @@ def raises(expected_exception, *args, **kwargs): :kwparam match: if specified, a string containing a regular expression, or a regular expression object, that is tested against the string - representation of the exception using ``re.match``. To match a literal + representation of the exception using ``re.search``. To match a literal string that may contain `special characters`__, the pattern can first be escaped with ``re.escape``. From a304dbb519aecf56022febe570958a8d64dae555 Mon Sep 17 00:00:00 2001 From: Akiomi Kamakura Date: Tue, 21 May 2019 09:48:22 +0900 Subject: [PATCH 08/22] Fix `disable_test_id_escaping_and_forfeit_all_rights_to_community_support` option when using a list of test IDs --- AUTHORS | 1 + changelog/5286.bugfix.rst | 1 + src/_pytest/python.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog/5286.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 95f763a96..0672d4abf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -9,6 +9,7 @@ Abhijeet Kasurde Adam Johnson Adam Uhlir Ahn Ki-Wook +Akiomi Kamakura Alan Velasco Alexander Johnson Alexei Kozlenok diff --git a/changelog/5286.bugfix.rst b/changelog/5286.bugfix.rst new file mode 100644 index 000000000..1d6974b89 --- /dev/null +++ b/changelog/5286.bugfix.rst @@ -0,0 +1 @@ +Fix issue with ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option doesn't work when using a list of test IDs in parametrized tests. diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 18d909855..b3754a2c2 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1217,7 +1217,7 @@ def _idvalset(idx, parameterset, argnames, idfn, ids, item, config): ] return "-".join(this_id) else: - return ascii_escaped(ids[idx]) + return _ascii_escaped_by_config(ids[idx], config) def idmaker(argnames, parametersets, idfn=None, ids=None, config=None, item=None): From c5fa1d1c3e1a6acac23cad3658ee529e42e3ef1e Mon Sep 17 00:00:00 2001 From: oleg-yegorov Date: Tue, 21 May 2019 09:40:31 +0300 Subject: [PATCH 09/22] Update fixture.rst add a missing import --- doc/en/fixture.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 23b32e9a7..ed9c11b2e 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -1179,6 +1179,8 @@ Given the tests file structure is: conftest.py # content of tests/conftest.py + import pytest + @pytest.fixture def username(): return 'username' From d391274f39f23f791a41776c7198aef3da791ee1 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 21 May 2019 11:12:07 -0300 Subject: [PATCH 10/22] Add link to tidelift to the main docs As commented in: https://github.com/pytest-dev/pytest/pull/5240#issuecomment-494175451 --- doc/en/contents.rst | 1 + doc/en/tidelift.rst | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 doc/en/tidelift.rst diff --git a/doc/en/contents.rst b/doc/en/contents.rst index 6bf97b453..1ec502c1f 100644 --- a/doc/en/contents.rst +++ b/doc/en/contents.rst @@ -50,6 +50,7 @@ Full pytest documentation projects faq contact + tidelift .. only:: html diff --git a/doc/en/tidelift.rst b/doc/en/tidelift.rst new file mode 100644 index 000000000..728bf2219 --- /dev/null +++ b/doc/en/tidelift.rst @@ -0,0 +1,4 @@ + + + +.. include:: ../../TIDELIFT.rst From 8a498700dafd2c05f0dd08afbd6b0c31ac372673 Mon Sep 17 00:00:00 2001 From: Akiomi Kamakura Date: Wed, 22 May 2019 03:56:52 +0900 Subject: [PATCH 11/22] Add tests for #5286 --- testing/python/metafunc.py | 96 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 29f18da36..945ab8627 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -229,6 +229,36 @@ class TestMetafunc(object): for val, expected in values: assert _idval(val, "a", 6, None, item=None, config=None) == expected + def test_unicode_idval_with_config(self): + """unittest for expected behavior to obtain ids with + disable_test_id_escaping_and_forfeit_all_rights_to_community_support + option. (#5294) + """ + from _pytest.python import _idval + + class MockConfig(object): + def __init__(self, config): + self.config = config + + @property + def hook(self): + return self + + def pytest_make_parametrize_id(self, **kw): + pass + + def getini(self, name): + return self.config[name] + + option = "disable_test_id_escaping_and_forfeit_all_rights_to_community_support" + + values = [ + (u"ação", MockConfig({option: True}), u"ação"), + (u"ação", MockConfig({option: False}), "a\\xe7\\xe3o"), + ] + for val, config, expected in values: + assert _idval(val, "a", 6, None, item=None, config=config) == expected + def test_bytes_idval(self): """unittest for the expected behavior to obtain ids for parametrized bytes values: @@ -394,6 +424,72 @@ class TestMetafunc(object): ) assert result == ["a-a0", "a-a1", "a-a2"] + def test_idmaker_with_idfn_and_config(self): + """unittest for expected behavior to create ids with idfn and + disable_test_id_escaping_and_forfeit_all_rights_to_community_support + option. (#5294) + """ + from _pytest.python import idmaker + + class MockConfig(object): + def __init__(self, config): + self.config = config + + @property + def hook(self): + return self + + def pytest_make_parametrize_id(self, **kw): + pass + + def getini(self, name): + return self.config[name] + + option = "disable_test_id_escaping_and_forfeit_all_rights_to_community_support" + + values = [ + (MockConfig({option: True}), u"ação"), + (MockConfig({option: False}), "a\\xe7\\xe3o"), + ] + for config, expected in values: + result = idmaker( + ("a",), [pytest.param("string")], idfn=lambda _: u"ação", config=config + ) + assert result == [expected] + + def test_idmaker_with_ids_and_config(self): + """unittest for expected behavior to create ids with ids and + disable_test_id_escaping_and_forfeit_all_rights_to_community_support + option. (#5294) + """ + from _pytest.python import idmaker + + class MockConfig(object): + def __init__(self, config): + self.config = config + + @property + def hook(self): + return self + + def pytest_make_parametrize_id(self, **kw): + pass + + def getini(self, name): + return self.config[name] + + option = "disable_test_id_escaping_and_forfeit_all_rights_to_community_support" + + values = [ + (MockConfig({option: True}), u"ação"), + (MockConfig({option: False}), "a\\xe7\\xe3o"), + ] + for config, expected in values: + result = idmaker( + ("a",), [pytest.param("string")], ids=[u"ação"], config=config + ) + assert result == [expected] + def test_parametrize_ids_exception(self, testdir): """ :param testdir: the instance of Testdir class, a temporary From 97b85a17ae9e4cc9cd512eff98e1f0d40dbe73d8 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 23 May 2019 08:38:54 +0200 Subject: [PATCH 12/22] changelog [ci skip] --- changelog/5278.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/5278.bugfix.rst diff --git a/changelog/5278.bugfix.rst b/changelog/5278.bugfix.rst new file mode 100644 index 000000000..88b211ba8 --- /dev/null +++ b/changelog/5278.bugfix.rst @@ -0,0 +1 @@ +Pytest's internal python plugin can be disabled using ``-p python`` now again. From a0ff5deabf74afe7839d6120f7e126375edc23d2 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 11 Mar 2019 15:47:07 +0100 Subject: [PATCH 13/22] pdb: trigger pytest_enter_pdb hook with post-mortem This is required for pytest-pdb to be called with `--pdb`. TODO: - [ ] test - [ ] pass mode to hook, e.g. "post_mortem" in this case? --- changelog/4908.bugfix.rst | 1 + src/_pytest/debugging.py | 27 ++++++++++++--------------- testing/test_pdb.py | 20 +++++++++++++++----- 3 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 changelog/4908.bugfix.rst diff --git a/changelog/4908.bugfix.rst b/changelog/4908.bugfix.rst new file mode 100644 index 000000000..2513618a1 --- /dev/null +++ b/changelog/4908.bugfix.rst @@ -0,0 +1 @@ +The ``pytest_enter_pdb`` hook gets called with post-mortem (``--pdb``). diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 52c6536f4..3c433b274 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -212,6 +212,17 @@ class pytestPDB(object): self._pytest_capman.suspend_global_capture(in_=True) return ret + def get_stack(self, f, t): + stack, i = super(PytestPdbWrapper, self).get_stack(f, t) + if f is None: + # Find last non-hidden frame. + i = max(0, len(stack) - 1) + while i and stack[i][0].f_locals.get( + "__tracebackhide__", False + ): + i -= 1 + return stack, i + _pdb = PytestPdbWrapper(**kwargs) cls._pluginmanager.hook.pytest_enter_pdb(config=cls._config, pdb=_pdb) else: @@ -298,22 +309,8 @@ def _postmortem_traceback(excinfo): return excinfo._excinfo[2] -def _find_last_non_hidden_frame(stack): - i = max(0, len(stack) - 1) - while i and stack[i][0].f_locals.get("__tracebackhide__", False): - i -= 1 - return i - - def post_mortem(t): - class Pdb(pytestPDB._pdb_cls, object): - def get_stack(self, f, t): - stack, i = super(Pdb, self).get_stack(f, t) - if f is None: - i = _find_last_non_hidden_frame(stack) - return stack, i - - p = Pdb() + p = pytestPDB._init_pdb() p.reset() p.interaction(None, t) if p.quitting: diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 3b21bacd9..9bac78557 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -744,7 +744,8 @@ class TestPDB(object): ["E NameError: *xxx*", "*! *Exit: Quitting debugger !*"] # due to EOF ) - def test_enter_leave_pdb_hooks_are_called(self, testdir): + @pytest.mark.parametrize("post_mortem", (False, True)) + def test_enter_leave_pdb_hooks_are_called(self, post_mortem, testdir): testdir.makeconftest( """ mypdb = None @@ -773,16 +774,25 @@ class TestPDB(object): """ import pytest - def test_foo(): + def test_set_trace(): pytest.set_trace() assert 0 + + def test_post_mortem(): + assert 0 """ ) - child = testdir.spawn_pytest(str(p1)) + if post_mortem: + child = testdir.spawn_pytest(str(p1) + " --pdb -s -k test_post_mortem") + else: + child = testdir.spawn_pytest(str(p1) + " -k test_set_trace") child.expect("enter_pdb_hook") child.sendline("c") - child.expect(r"PDB continue \(IO-capturing resumed\)") - child.expect("Captured stdout call") + if post_mortem: + child.expect(r"PDB continue") + else: + child.expect(r"PDB continue \(IO-capturing resumed\)") + child.expect("Captured stdout call") rest = child.read().decode("utf8") assert "leave_pdb_hook" in rest assert "1 failed" in rest From e0b584d0485329bad3b881c0c7a4e040f4b0b6dd Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 23 May 2019 08:56:52 +0200 Subject: [PATCH 14/22] CaptureFixture: do not crash in _suspend when not started This happened in test_pdb_with_caplog_on_pdb_invocation. --- src/_pytest/capture.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 560171134..84f773254 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -358,8 +358,7 @@ class CaptureFixture(object): self._captured_err = self.captureclass.EMPTY_BUFFER def _start(self): - # Start if not started yet - if getattr(self, "_capture", None) is None: + if self._capture is None: self._capture = MultiCapture( out=True, err=True, in_=False, Capture=self.captureclass ) @@ -389,11 +388,13 @@ class CaptureFixture(object): def _suspend(self): """Suspends this fixture's own capturing temporarily.""" - self._capture.suspend_capturing() + if self._capture is not None: + self._capture.suspend_capturing() def _resume(self): """Resumes this fixture's own capturing temporarily.""" - self._capture.resume_capturing() + if self._capture is not None: + self._capture.resume_capturing() @contextlib.contextmanager def disabled(self): From 0cacdadc978f4f5ec2b5da53dbaaf37401ff8a33 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 23 May 2019 12:36:46 -0300 Subject: [PATCH 15/22] Create FUNDING.yml Following instructions from: * https://tidelift.com/subscription/how-to-connect-tidelift-with-github * https://help.github.com/en/articles/displaying-a-sponsor-button-in-your-repository#displaying-a-sponsor-button-in-your-repository --- .github/FUNDING.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..ad5f776fb --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# info: +# * https://help.github.com/en/articles/displaying-a-sponsor-button-in-your-repository +# * https://tidelift.com/subscription/how-to-connect-tidelift-with-github +tidelift: pypi/pytest From aaea4e52efaa978c8d8b21729b053db3277e630d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 23 May 2019 12:44:55 -0300 Subject: [PATCH 16/22] Fix whitespace in FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index ad5f776fb..1307445eb 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,4 +1,4 @@ -# info: +# info: # * https://help.github.com/en/articles/displaying-a-sponsor-button-in-your-repository # * https://tidelift.com/subscription/how-to-connect-tidelift-with-github tidelift: pypi/pytest From 84c7fef8360849e24e008af002645a5d7e645144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6thlisberger?= Date: Thu, 23 May 2019 16:48:39 +0100 Subject: [PATCH 17/22] changelog: Fix typo --- changelog/5278.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/5278.bugfix.rst b/changelog/5278.bugfix.rst index 88b211ba8..4fe70c7fd 100644 --- a/changelog/5278.bugfix.rst +++ b/changelog/5278.bugfix.rst @@ -1 +1 @@ -Pytest's internal python plugin can be disabled using ``-p python`` now again. +Pytest's internal python plugin can be disabled using ``-p no:python`` again. From 31dfbb46686838e515d43188369c83cd3c397648 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Fri, 24 May 2019 04:32:22 +0200 Subject: [PATCH 18/22] logging: Simple impl of multline pretty printing --- src/_pytest/logging.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 660912c91..29524e7fb 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -41,6 +41,21 @@ class ColoredLevelFormatter(logging.Formatter): if six.PY2: self._original_fmt = self._fmt else: + + class PercentStyleMultiline(logging.PercentStyle): + def format(self, record): + if "\n" in record.message: + fmt = self._fmt + dct = record.__dict__ + data_seq = [ + fmt % {**dct, "message": line} + for line in record.message.splitlines() + ] + return "\n".join(data_seq) + else: + return self._fmt % record.__dict__ + + self._style = PercentStyleMultiline(self._style._fmt) self._original_fmt = self._style._fmt self._level_to_fmt_mapping = {} From bed3918cbc800682681a26c163f4cb0868b3a612 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Fri, 24 May 2019 09:11:03 +0200 Subject: [PATCH 19/22] Revert "logging: Simple impl of multline pretty printing" This reverts commit 31dfbb46686838e515d43188369c83cd3c397648. --- src/_pytest/logging.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 29524e7fb..660912c91 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -41,21 +41,6 @@ class ColoredLevelFormatter(logging.Formatter): if six.PY2: self._original_fmt = self._fmt else: - - class PercentStyleMultiline(logging.PercentStyle): - def format(self, record): - if "\n" in record.message: - fmt = self._fmt - dct = record.__dict__ - data_seq = [ - fmt % {**dct, "message": line} - for line in record.message.splitlines() - ] - return "\n".join(data_seq) - else: - return self._fmt % record.__dict__ - - self._style = PercentStyleMultiline(self._style._fmt) self._original_fmt = self._style._fmt self._level_to_fmt_mapping = {} From e393a7389071854f2ff8b9f5e116a7f51cf0b93d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 24 May 2019 12:11:15 -0300 Subject: [PATCH 20/22] Small change to test if pushing directly to master is disabled --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index aaf13b1a4..590cc9958 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,7 @@ From f2ed796c41516f35b54e668eb469787df132d7b3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 24 May 2019 18:10:05 +0200 Subject: [PATCH 21/22] pdb: import pdbcls lazily Fixes https://github.com/pytest-dev/pytest/issues/2064. --- changelog/2064.bugfix.rst | 1 + src/_pytest/debugging.py | 62 +++++++++++++++++++++------------------ testing/test_pdb.py | 7 +++-- 3 files changed, 38 insertions(+), 32 deletions(-) create mode 100644 changelog/2064.bugfix.rst diff --git a/changelog/2064.bugfix.rst b/changelog/2064.bugfix.rst new file mode 100644 index 000000000..eba593fc5 --- /dev/null +++ b/changelog/2064.bugfix.rst @@ -0,0 +1 @@ +The debugging plugin imports the wrapped ``Pdb`` class (``--pdbcls``) on-demand now. diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 3605490e6..8912477db 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -49,42 +49,18 @@ def pytest_addoption(parser): ) -def _import_pdbcls(modname, classname): - try: - __import__(modname) - mod = sys.modules[modname] - - # Handle --pdbcls=pdb:pdb.Pdb (useful e.g. with pdbpp). - parts = classname.split(".") - pdb_cls = getattr(mod, parts[0]) - for part in parts[1:]: - pdb_cls = getattr(pdb_cls, part) - - return pdb_cls - except Exception as exc: - value = ":".join((modname, classname)) - raise UsageError("--pdbcls: could not import {!r}: {}".format(value, exc)) - - def pytest_configure(config): - pdb_cls = config.getvalue("usepdb_cls") - if pdb_cls: - pdb_cls = _import_pdbcls(*pdb_cls) - else: - pdb_cls = pdb.Pdb - if config.getvalue("trace"): config.pluginmanager.register(PdbTrace(), "pdbtrace") if config.getvalue("usepdb"): config.pluginmanager.register(PdbInvoke(), "pdbinvoke") pytestPDB._saved.append( - (pdb.set_trace, pytestPDB._pluginmanager, pytestPDB._config, pytestPDB._pdb_cls) + (pdb.set_trace, pytestPDB._pluginmanager, pytestPDB._config) ) pdb.set_trace = pytestPDB.set_trace pytestPDB._pluginmanager = config.pluginmanager pytestPDB._config = config - pytestPDB._pdb_cls = pdb_cls # NOTE: not using pytest_unconfigure, since it might get called although # pytest_configure was not (if another plugin raises UsageError). @@ -93,7 +69,6 @@ def pytest_configure(config): pdb.set_trace, pytestPDB._pluginmanager, pytestPDB._config, - pytestPDB._pdb_cls, ) = pytestPDB._saved.pop() config._cleanup.append(fin) @@ -104,7 +79,6 @@ class pytestPDB(object): _pluginmanager = None _config = None - _pdb_cls = pdb.Pdb _saved = [] _recursive_debug = 0 @@ -114,6 +88,33 @@ class pytestPDB(object): return capman.is_capturing() return False + @classmethod + def _import_pdb_cls(cls): + if not cls._config: + # Happens when using pytest.set_trace outside of a test. + return pdb.Pdb + + pdb_cls = cls._config.getvalue("usepdb_cls") + if not pdb_cls: + return pdb.Pdb + + modname, classname = pdb_cls + + try: + __import__(modname) + mod = sys.modules[modname] + + # Handle --pdbcls=pdb:pdb.Pdb (useful e.g. with pdbpp). + parts = classname.split(".") + pdb_cls = getattr(mod, parts[0]) + for part in parts[1:]: + pdb_cls = getattr(pdb_cls, part) + + return pdb_cls + except Exception as exc: + value = ":".join((modname, classname)) + raise UsageError("--pdbcls: could not import {!r}: {}".format(value, exc)) + @classmethod def _init_pdb(cls, *args, **kwargs): """ Initialize PDB debugging, dropping any IO capturing. """ @@ -144,7 +145,9 @@ class pytestPDB(object): else: tw.sep(">", "PDB set_trace") - class PytestPdbWrapper(cls._pdb_cls, object): + pdb_cls = cls._import_pdb_cls() + + class PytestPdbWrapper(pdb_cls, object): _pytest_capman = capman _continued = False @@ -227,7 +230,8 @@ class pytestPDB(object): _pdb = PytestPdbWrapper(**kwargs) cls._pluginmanager.hook.pytest_enter_pdb(config=cls._config, pdb=_pdb) else: - _pdb = cls._pdb_cls(**kwargs) + pdb_cls = cls._import_pdb_cls() + _pdb = pdb_cls(**kwargs) return _pdb @classmethod diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 4b084a26a..007423a9e 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -1157,12 +1157,13 @@ def test_pdbcls_via_local_module(testdir): result = testdir.runpytest( str(p1), "--pdbcls=really.invalid:Value", syspathinsert=True ) - result.stderr.fnmatch_lines( + result.stdout.fnmatch_lines( [ - "ERROR: --pdbcls: could not import 'really.invalid:Value': No module named *really*" + "*= FAILURES =*", + "E * --pdbcls: could not import 'really.invalid:Value': No module named *really*", ] ) - assert result.ret == 4 + assert result.ret == 1 result = testdir.runpytest( str(p1), "--pdbcls=mypdb:Wrapped.MyPdb", syspathinsert=True From e38561037d9c9697637f0af83e1a0fa628e7d310 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 27 May 2019 19:25:33 -0300 Subject: [PATCH 22/22] Update docs about py27 and py34 support plans As discussed in #5275 --- doc/en/py27-py34-deprecation.rst | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/en/py27-py34-deprecation.rst b/doc/en/py27-py34-deprecation.rst index 97d9abf83..95e96de04 100644 --- a/doc/en/py27-py34-deprecation.rst +++ b/doc/en/py27-py34-deprecation.rst @@ -7,16 +7,20 @@ Python 3.4's last release is scheduled for `March 2019 `__. pytest is one of the participating projects of the https://python3statement.org. -We plan to drop support for Python 2.7 and 3.4 at the same time with the release of **pytest 5.0**, -scheduled to be released by **mid-2019**. Thanks to the `python_requires `__ ``setuptools`` option, +The **pytest 4.6** series will be the last to support Python 2.7 and 3.4, and is scheduled +to be released by **mid-2019**. **pytest 5.0** and onwards will support only Python 3.5+. + +Thanks to the `python_requires`_ ``setuptools`` option, Python 2.7 and Python 3.4 users using a modern ``pip`` version -will install the last compatible pytest ``4.X`` version automatically even if ``5.0`` or later +will install the last pytest ``4.6`` version automatically even if ``5.0`` or later are available on PyPI. -During the period **from mid-2019 and 2020**, the pytest core team plans to make -bug-fix releases of the pytest ``4.X`` series by back-porting patches to the ``4.x-maintenance`` -branch. +While pytest ``5.0`` will be the new mainstream and development version, until **January 2020** +the pytest core team plans to make bug-fix releases of the pytest ``4.6`` series by +back-porting patches to the ``4.6-maintenance`` branch that affect Python 2 users. -**After 2020**, the core team will no longer actively back port-patches, but the ``4.x-maintenance`` -branch will continue to exist so the community itself can contribute patches. The -core team will be happy to accept those patches and make new ``4.X`` releases **until mid-2020**. +**After 2020**, the core team will no longer actively backport patches, but the ``4.6-maintenance`` +branch will continue to exist so the community itself can contribute patches. The core team will +be happy to accept those patches and make new ``4.6`` releases **until mid-2020**. + +.. _`python_requires`: https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires>