Clean up __future__ and coding: in tests

This commit is contained in:
Anthony Sottile
2019-06-02 15:40:34 -07:00
committed by Bruno Oliveira
parent a91fe1fedd
commit 4df529e5b9
15 changed files with 27 additions and 63 deletions

View 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*"])

View File

@@ -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()