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,14 +507,13 @@ 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'])
|
||||
def test_foo(data):
|
||||
assert data
|
||||
"""
|
||||
"""
|
||||
)
|
||||
res = testdir.runpytest(p)
|
||||
res.assert_outcomes(passed=3)
|
||||
|
|
|
@ -840,16 +840,14 @@ def test_log_file_unicode(testdir):
|
|||
)
|
||||
)
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
"""\
|
||||
import logging
|
||||
|
||||
def test_log_file():
|
||||
logging.getLogger('catchlog').info("Normal message")
|
||||
logging.getLogger('catchlog').info("├")
|
||||
logging.getLogger('catchlog').info("Another normal message")
|
||||
"""
|
||||
"""
|
||||
)
|
||||
|
||||
result = testdir.runpytest()
|
||||
|
|
|
@ -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,11 +1217,10 @@ 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'
|
||||
"""
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(["*AssertionError*"])
|
||||
|
|
|
@ -95,14 +95,13 @@ 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
|
||||
print(sys.stdout)
|
||||
print(%s)
|
||||
"""
|
||||
"""
|
||||
% obj
|
||||
)
|
||||
result = testdir.runpytest("--capture=%s" % method)
|
||||
|
@ -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,14 +574,13 @@ 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'.
|
||||
'anything'
|
||||
"""
|
||||
'''
|
||||
'''
|
||||
)
|
||||
result = testdir.runpytest("--doctest-modules")
|
||||
result.stdout.fnmatch_lines(["Got nothing", "* 1 failed in*"])
|
||||
|
@ -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,12 +567,12 @@ class TestPython:
|
|||
def test_unicode(self, testdir):
|
||||
value = "hx\xc4\x85\xc4\x87\n"
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
"""\
|
||||
# coding: latin1
|
||||
def test_hello():
|
||||
print(%r)
|
||||
assert 0
|
||||
"""
|
||||
"""
|
||||
% value
|
||||
)
|
||||
result, dom = runandparse(testdir)
|
||||
|
|
|
@ -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,13 +366,12 @@ 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):
|
||||
raise unittest.SkipTest(u'😊')
|
||||
"""
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(["* 1 skipped *"])
|
||||
|
|
|
@ -60,11 +60,10 @@ class TestPasteCapture:
|
|||
correctly. See #1219.
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
test_unicode="""
|
||||
# -*- coding: utf-8 -*-
|
||||
test_unicode="""\
|
||||
def test():
|
||||
assert '☺' == 1
|
||||
"""
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest("--pastebin=all")
|
||||
expected_msg = "*assert '☺' == 1*"
|
||||
|
|
|
@ -149,12 +149,11 @@ 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()
|
||||
"""
|
||||
"""
|
||||
)
|
||||
with pytest.raises(ImportError) as excinfo:
|
||||
pytestpm.import_plugin("qwe")
|
||||
|
|
|
@ -639,13 +639,12 @@ 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():
|
||||
pytest.fail(%s'oh oh: ☺', pytrace=False)
|
||||
"""
|
||||
"""
|
||||
% str_prefix
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
|
@ -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():
|
||||
|
@ -793,7 +791,7 @@ def test_unicode_in_longrepr(testdir):
|
|||
rep = outcome.get_result()
|
||||
if rep.when == "call":
|
||||
rep.longrepr = u'ä'
|
||||
"""
|
||||
"""
|
||||
)
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -136,7 +135,7 @@ def test_unicode(testdir, pyfile_with_warnings):
|
|||
|
||||
def test_func(fix):
|
||||
pass
|
||||
"""
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(
|
||||
|
|
Loading…
Reference in New Issue