Clean up __future__ and coding: in tests
This commit is contained in:
parent
a91fe1fedd
commit
4df529e5b9
|
@ -335,8 +335,6 @@ string value of ``Hello World!`` if we do not supply a value or ``Hello
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -507,8 +507,7 @@ class TestGeneralUsage:
|
|||
def test_parametrized_with_null_bytes(self, testdir):
|
||||
"""Test parametrization with values that contain null bytes and unicode characters (#2644, #2957)"""
|
||||
p = testdir.makepyfile(
|
||||
"""
|
||||
# encoding: UTF-8
|
||||
"""\
|
||||
import pytest
|
||||
|
||||
@pytest.mark.parametrize("data", [b"\\x00", "\\x00", u'ação'])
|
||||
|
|
|
@ -840,9 +840,7 @@ def test_log_file_unicode(testdir):
|
|||
)
|
||||
)
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
"""\
|
||||
import logging
|
||||
|
||||
def test_log_file():
|
||||
|
|
|
@ -116,12 +116,7 @@ class TestModule:
|
|||
"""Check test modules collected which raise ImportError with unicode messages
|
||||
are handled properly (#2336).
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
raise ImportError(u'Something bad happened ☺')
|
||||
"""
|
||||
)
|
||||
testdir.makepyfile("raise ImportError(u'Something bad happened ☺')")
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
|
@ -1256,13 +1251,7 @@ def test_class_injection_does_not_break_collection(testdir):
|
|||
def test_syntax_error_with_non_ascii_chars(testdir):
|
||||
"""Fix decoding issue while formatting SyntaxErrors during collection (#578)
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
☃
|
||||
"""
|
||||
)
|
||||
testdir.makepyfile("☃")
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(["*ERROR collecting*", "*SyntaxError*", "*1 error in*"])
|
||||
|
||||
|
|
|
@ -3338,7 +3338,6 @@ class TestContextManagerFixtureFuncs:
|
|||
def test_simple(self, testdir, flavor):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from test_context import fixture
|
||||
@fixture
|
||||
def arg1():
|
||||
|
@ -3367,7 +3366,6 @@ class TestContextManagerFixtureFuncs:
|
|||
def test_scoped(self, testdir, flavor):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from test_context import fixture
|
||||
@fixture(scope="module")
|
||||
def arg1():
|
||||
|
@ -3601,7 +3599,6 @@ class TestParameterizedSubRequest:
|
|||
def test_pytest_fixture_setup_and_post_finalizer_hook(testdir):
|
||||
testdir.makeconftest(
|
||||
"""
|
||||
from __future__ import print_function
|
||||
def pytest_fixture_setup(fixturedef, request):
|
||||
print('ROOT setup hook called for {0} from {1}'.format(fixturedef.argname, request.node.name))
|
||||
def pytest_fixture_post_finalizer(fixturedef, request):
|
||||
|
@ -3611,14 +3608,12 @@ def test_pytest_fixture_setup_and_post_finalizer_hook(testdir):
|
|||
testdir.makepyfile(
|
||||
**{
|
||||
"tests/conftest.py": """
|
||||
from __future__ import print_function
|
||||
def pytest_fixture_setup(fixturedef, request):
|
||||
print('TESTS setup hook called for {0} from {1}'.format(fixturedef.argname, request.node.name))
|
||||
def pytest_fixture_post_finalizer(fixturedef, request):
|
||||
print('TESTS finalizer hook called for {0} from {1}'.format(fixturedef.argname, request.node.name))
|
||||
""",
|
||||
"tests/test_hooks.py": """
|
||||
from __future__ import print_function
|
||||
import pytest
|
||||
|
||||
@pytest.fixture()
|
||||
|
|
|
@ -1217,8 +1217,7 @@ def test_assert_indirect_tuple_no_warning(testdir):
|
|||
|
||||
def test_assert_with_unicode(monkeypatch, testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
"""\
|
||||
def test_unicode():
|
||||
assert u'유니코드' == u'Unicode'
|
||||
"""
|
||||
|
|
|
@ -95,8 +95,7 @@ def test_capturing_unicode(testdir, method):
|
|||
pytest.xfail("does not work on pypy < 2.2")
|
||||
obj = "'b\u00f6y'"
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
"""\
|
||||
# taken from issue 227 from nosetests
|
||||
def test_unicode():
|
||||
import sys
|
||||
|
@ -624,7 +623,6 @@ class TestCaptureFixture:
|
|||
"""
|
||||
testdir.makepyfile(
|
||||
"""\
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import pytest
|
||||
|
||||
|
@ -1363,7 +1361,6 @@ def test_dontreadfrominput_has_encoding(testdir):
|
|||
def test_crash_on_closing_tmpfile_py27(testdir):
|
||||
p = testdir.makepyfile(
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import threading
|
||||
import sys
|
||||
|
||||
|
|
|
@ -574,8 +574,7 @@ class TestDoctests:
|
|||
"""Fix internal error with docstrings containing non-ascii characters.
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
'''
|
||||
# -*- coding: utf-8 -*-
|
||||
'''\
|
||||
def foo():
|
||||
"""
|
||||
>>> name = 'с' # not letter 'c' but instead Cyrillic 's'.
|
||||
|
@ -652,9 +651,6 @@ class TestDoctests:
|
|||
"""
|
||||
p = testdir.makepyfile(
|
||||
test_unicode_doctest_module="""
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
def fix_bad_unicode(text):
|
||||
'''
|
||||
>>> print(fix_bad_unicode('único'))
|
||||
|
|
|
@ -567,7 +567,7 @@ class TestPython:
|
|||
def test_unicode(self, testdir):
|
||||
value = "hx\xc4\x85\xc4\x87\n"
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
"""\
|
||||
# coding: latin1
|
||||
def test_hello():
|
||||
print(%r)
|
||||
|
|
|
@ -960,7 +960,6 @@ def test_markers_from_parametrize(testdir):
|
|||
"""#3605"""
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import pytest
|
||||
|
||||
first_custom_mark = pytest.mark.custom_marker
|
||||
|
|
|
@ -366,8 +366,7 @@ def test_nottest_class_decorator(testdir):
|
|||
|
||||
def test_skip_test_with_unicode(testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
"""\
|
||||
import unittest
|
||||
class TestClass():
|
||||
def test_io(self):
|
||||
|
|
|
@ -60,8 +60,7 @@ class TestPasteCapture:
|
|||
correctly. See #1219.
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
test_unicode="""
|
||||
# -*- coding: utf-8 -*-
|
||||
test_unicode="""\
|
||||
def test():
|
||||
assert '☺' == 1
|
||||
"""
|
||||
|
|
|
@ -149,10 +149,9 @@ def test_importplugin_error_message(testdir, pytestpm):
|
|||
"""
|
||||
testdir.syspathinsert(testdir.tmpdir)
|
||||
testdir.makepyfile(
|
||||
qwe="""
|
||||
# -*- coding: utf-8 -*-
|
||||
qwe="""\
|
||||
def test_traceback():
|
||||
raise ImportError(u'Not possible to import: ☺')
|
||||
raise ImportError('Not possible to import: ☺')
|
||||
test_traceback()
|
||||
"""
|
||||
)
|
||||
|
|
|
@ -639,8 +639,7 @@ def test_pytest_fail_notrace_non_ascii(testdir, str_prefix):
|
|||
This tests with native and unicode strings containing non-ascii chars.
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
"""\
|
||||
import pytest
|
||||
|
||||
def test_hello():
|
||||
|
@ -784,8 +783,7 @@ def test_pytest_cmdline_main(testdir):
|
|||
|
||||
def test_unicode_in_longrepr(testdir):
|
||||
testdir.makeconftest(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
"""\
|
||||
import pytest
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
def pytest_runtest_makereport():
|
||||
|
|
|
@ -123,8 +123,7 @@ def test_ignore(testdir, pyfile_with_warnings, method):
|
|||
@pytest.mark.filterwarnings("always")
|
||||
def test_unicode(testdir, pyfile_with_warnings):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
"""\
|
||||
import warnings
|
||||
import pytest
|
||||
|
||||
|
|
Loading…
Reference in New Issue