From 4ae93a7a078fc92d910b632a46a86cb779b3e2b7 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 8 Jul 2018 08:35:53 -0700 Subject: [PATCH] Remove obsolete __future__ imports --- changelog/2319.trivial.rst | 1 + src/_pytest/_code/source.py | 13 +++---------- testing/python/raises.py | 3 +-- testing/test_assertrewrite.py | 6 +++--- testing/test_capture.py | 1 - 5 files changed, 8 insertions(+), 16 deletions(-) create mode 100644 changelog/2319.trivial.rst diff --git a/changelog/2319.trivial.rst b/changelog/2319.trivial.rst new file mode 100644 index 000000000..a69ec1345 --- /dev/null +++ b/changelog/2319.trivial.rst @@ -0,0 +1 @@ +Remove obsolete ``__future__`` imports. diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py index 711408f61..3b037b7d4 100644 --- a/src/_pytest/_code/source.py +++ b/src/_pytest/_code/source.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, division, generators, print_function +from __future__ import absolute_import, division, print_function import ast from ast import PyCF_ONLY_AST as _AST_FLAG @@ -152,12 +152,7 @@ class Source(object): return "\n".join(self.lines) def compile( - self, - filename=None, - mode="exec", - flag=generators.compiler_flag, - dont_inherit=0, - _genframe=None, + self, filename=None, mode="exec", flag=0, dont_inherit=0, _genframe=None ): """ return compiled code object. if filename is None invent an artificial filename which displays @@ -201,9 +196,7 @@ class Source(object): # -def compile_( - source, filename=None, mode="exec", flags=generators.compiler_flag, dont_inherit=0 -): +def compile_(source, filename=None, mode="exec", flags=0, dont_inherit=0): """ compile the given source to a raw code object, and maintain an internal cache which allows later retrieval of the source code for the code object diff --git a/testing/python/raises.py b/testing/python/raises.py index 99aeffdf2..732e1e82c 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -33,8 +33,7 @@ class TestRaises(object): def test_raises_as_contextmanager(self, testdir): testdir.makepyfile( """ - from __future__ import with_statement - import py, pytest + import pytest import _pytest._code def test_simple(): diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 20cc476d8..2640beb63 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -97,7 +97,7 @@ class TestAssertionRewrite(object): assert imp.lineno == 2 assert imp.col_offset == 0 assert isinstance(m.body[2], ast.Assign) - s = """from __future__ import with_statement\nother_stuff""" + s = """from __future__ import division\nother_stuff""" m = rewrite(s) assert isinstance(m.body[0], ast.ImportFrom) for imp in m.body[1:3]: @@ -105,7 +105,7 @@ class TestAssertionRewrite(object): assert imp.lineno == 2 assert imp.col_offset == 0 assert isinstance(m.body[3], ast.Expr) - s = """'doc string'\nfrom __future__ import with_statement""" + s = """'doc string'\nfrom __future__ import division""" m = rewrite(s) adjust_body_for_new_docstring_in_module_node(m) assert isinstance(m.body[0], ast.ImportFrom) @@ -113,7 +113,7 @@ class TestAssertionRewrite(object): assert isinstance(imp, ast.Import) assert imp.lineno == 2 assert imp.col_offset == 0 - s = """'doc string'\nfrom __future__ import with_statement\nother""" + s = """'doc string'\nfrom __future__ import division\nother""" m = rewrite(s) adjust_body_for_new_docstring_in_module_node(m) assert isinstance(m.body[0], ast.ImportFrom) diff --git a/testing/test_capture.py b/testing/test_capture.py index 54f0fbc44..5f5e1b98d 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, division, print_function # note: py.io capture tests where copied from # pylib 1.4.20.dev2 (rev 13d9af95547e) -from __future__ import with_statement import pickle import os import sys