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