Hello community,
here is the log from the commit of package python-autopep8 for openSUSE:Factory
checked in at 2020-01-22 22:46:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-autopep8 (Old)
and /work/SRC/openSUSE:Factory/.python-autopep8.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-autopep8"
Wed Jan 22 22:46:33 2020 rev:17 rq:766347 version:1.5
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-autopep8/python-autopep8.changes
2019-04-23 14:39:06.941580714 +0200
+++
/work/SRC/openSUSE:Factory/.python-autopep8.new.26092/python-autopep8.changes
2020-01-22 22:46:53.092594178 +0100
@@ -1,0 +2,8 @@
+Wed Jan 22 15:04:41 UTC 2020 - Marketa Calabkova <[email protected]>
+
+- update to 1.5
+ * Support Python3.8
+ * Support pyproject.toml with [tool.autopep8] section.
+ * fix few bugs
+
+-------------------------------------------------------------------
Old:
----
autopep8-1.4.4.tar.gz
New:
----
autopep8-1.5.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-autopep8.spec ++++++
--- /var/tmp/diff_new_pack.IxDyHz/_old 2020-01-22 22:46:54.404594838 +0100
+++ /var/tmp/diff_new_pack.IxDyHz/_new 2020-01-22 22:46:54.420594846 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-autopep8
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-autopep8
-Version: 1.4.4
+Version: 1.5
Release: 0
Summary: Automatic generated to pep8 checked code
License: MIT
++++++ autopep8-1.4.4.tar.gz -> autopep8-1.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.4/PKG-INFO new/autopep8-1.5/PKG-INFO
--- old/autopep8-1.4.4/PKG-INFO 2019-04-14 10:29:35.000000000 +0200
+++ new/autopep8-1.5/PKG-INFO 2020-01-20 15:08:06.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: autopep8
-Version: 1.4.4
+Version: 1.5
Summary: A tool that automatically formats Python code to conform to the PEP 8
style guide
Home-page: https://github.com/hhatto/autopep8
Author: Hideo Hattori
@@ -319,6 +319,13 @@
$ autopep8 -v <filename>
+ Passing in ``--experimental`` enables the following functionality:
+
+ - Shortens code lines by taking its length into account
+
+ ::
+
+ $ autopep8 --experimental <filename>
Use as a module
===============
@@ -361,6 +368,19 @@
max_line_length = 120
ignore = E501
+ pyproject.toml
+ --------------
+
+ autopep8 can also use ``pyproject.toml``.
+ section must use ``[tool.autopep8]``, and ``pyproject.toml`` takes
precedence
+ over any other configuration files.
+
+ configuration file example::
+
+ [tool.autopep8]
+ max_line_length = 120
+ ignore = E501
+
Testing
=======
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.4/README.rst new/autopep8-1.5/README.rst
--- old/autopep8-1.4.4/README.rst 2019-04-14 10:29:22.000000000 +0200
+++ new/autopep8-1.5/README.rst 2020-01-04 15:48:57.000000000 +0100
@@ -311,6 +311,13 @@
$ autopep8 -v <filename>
+Passing in ``--experimental`` enables the following functionality:
+
+- Shortens code lines by taking its length into account
+
+::
+
+$ autopep8 --experimental <filename>
Use as a module
===============
@@ -353,6 +360,19 @@
max_line_length = 120
ignore = E501
+pyproject.toml
+--------------
+
+autopep8 can also use ``pyproject.toml``.
+section must use ``[tool.autopep8]``, and ``pyproject.toml`` takes precedence
+over any other configuration files.
+
+configuration file example::
+
+ [tool.autopep8]
+ max_line_length = 120
+ ignore = E501
+
Testing
=======
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.4/autopep8.egg-info/PKG-INFO
new/autopep8-1.5/autopep8.egg-info/PKG-INFO
--- old/autopep8-1.4.4/autopep8.egg-info/PKG-INFO 2019-04-14
10:29:35.000000000 +0200
+++ new/autopep8-1.5/autopep8.egg-info/PKG-INFO 2020-01-20 15:08:06.000000000
+0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: autopep8
-Version: 1.4.4
+Version: 1.5
Summary: A tool that automatically formats Python code to conform to the PEP 8
style guide
Home-page: https://github.com/hhatto/autopep8
Author: Hideo Hattori
@@ -319,6 +319,13 @@
$ autopep8 -v <filename>
+ Passing in ``--experimental`` enables the following functionality:
+
+ - Shortens code lines by taking its length into account
+
+ ::
+
+ $ autopep8 --experimental <filename>
Use as a module
===============
@@ -361,6 +368,19 @@
max_line_length = 120
ignore = E501
+ pyproject.toml
+ --------------
+
+ autopep8 can also use ``pyproject.toml``.
+ section must use ``[tool.autopep8]``, and ``pyproject.toml`` takes
precedence
+ over any other configuration files.
+
+ configuration file example::
+
+ [tool.autopep8]
+ max_line_length = 120
+ ignore = E501
+
Testing
=======
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.4/autopep8.egg-info/requires.txt
new/autopep8-1.5/autopep8.egg-info/requires.txt
--- old/autopep8-1.4.4/autopep8.egg-info/requires.txt 2019-04-14
10:29:35.000000000 +0200
+++ new/autopep8-1.5/autopep8.egg-info/requires.txt 2020-01-20
15:08:06.000000000 +0100
@@ -1 +1 @@
-pycodestyle>=2.4.0
+pycodestyle>=2.5.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.4/autopep8.py
new/autopep8-1.5/autopep8.py
--- old/autopep8-1.4.4/autopep8.py 2019-04-14 10:29:22.000000000 +0200
+++ new/autopep8-1.5/autopep8.py 2020-01-20 15:07:31.000000000 +0100
@@ -48,6 +48,7 @@
import fnmatch
import inspect
import io
+import itertools
import keyword
import locale
import os
@@ -58,6 +59,12 @@
import token
import tokenize
import ast
+try:
+ from configparser import ConfigParser as SafeConfigParser
+ from configparser import Error
+except ImportError:
+ from ConfigParser import SafeConfigParser
+ from ConfigParser import Error
import pycodestyle
@@ -68,7 +75,7 @@
unicode = str
-__version__ = '1.4.4'
+__version__ = '1.5'
CR = '\r'
@@ -645,6 +652,19 @@
self.source[line_index] = indent[1:] + stripped
+ def fix_e117(self, result):
+ """Fix over-indented."""
+ line_index = result['line'] - 1
+ target = self.source[line_index]
+
+ indent = _get_indentation(target)
+ if indent == '\t':
+ return []
+
+ stripped = target.lstrip()
+
+ self.source[line_index] = indent[1:] + stripped
+
def fix_e125(self, result):
"""Fix indentation undistinguish from the next logical line."""
num_indent_spaces = int(result['info'].split()[1])
@@ -1064,9 +1084,6 @@
center = target[offset:right_offset]
right = target[right_offset:].lstrip()
- if not right.startswith('None'):
- return []
-
if center.strip() == '==':
new_center = 'is'
elif center.strip() == '!=':
@@ -1284,8 +1301,14 @@
before_line[:comment_index], one_string_token,
before_line[comment_index + 1:])
else:
- self.source[fix_target_line] = '{} {}{}'.format(
- before_line[:bl], one_string_token, before_line[bl:])
+ if before_line[:bl].endswith("#"):
+ # special case
+ # see: https://github.com/hhatto/autopep8/issues/503
+ self.source[fix_target_line] = '{}{} {}'.format(
+ before_line[:bl-2], one_string_token, before_line[bl-2:])
+ else:
+ self.source[fix_target_line] = '{} {}{}'.format(
+ before_line[:bl], one_string_token, before_line[bl:])
def fix_w504(self, result):
(line_index, _, target) = get_index_offset_contents(result,
@@ -1353,6 +1376,12 @@
except (SyntaxError, tokenize.TokenError):
return
for (pos, _msg) in get_w605_position(tokens):
+ if target[pos - 1] == "r":
+ # ignore special case
+ if self.options.verbose:
+ print("invalid line: line_number={}, line: {}".format(
+ line_index + 1, target))
+ return
self.source[line_index] = '{}r{}'.format(
target[:pos], target[pos:])
@@ -1415,10 +1444,24 @@
return True
return False
+ def has_future_import(source):
+ offset = 0
+ line = ''
+ for _, next_line in source:
+ for line_part in next_line.strip().splitlines(True):
+ line = line + line_part
+ try:
+ return is_future_import(line), offset
+ except SyntaxError:
+ continue
+ offset += 1
+ return False, offset
+
allowed_try_keywords = ('try', 'except', 'else', 'finally')
in_docstring = False
docstring_kind = '"""'
- for cnt, line in enumerate(source):
+ source_stream = iter(enumerate(source))
+ for cnt, line in source_stream:
if not in_docstring:
m = DOCSTRING_START_REGEX.match(line.lstrip())
if m is not None:
@@ -1438,10 +1481,20 @@
elif line.startswith('#'):
continue
- if line.startswith('import ') or line.startswith('from '):
- if cnt == import_line_index or is_future_import(line):
+ if line.startswith('import '):
+ if cnt == import_line_index:
continue
return cnt
+ elif line.startswith('from '):
+ if cnt == import_line_index:
+ continue
+ hit, offset = has_future_import(
+ itertools.chain([(cnt, line)], source_stream)
+ )
+ if hit:
+ # move to the back
+ return cnt + offset + 1
+ return cnt
elif pycodestyle.DUNDER_REGEX.match(line):
continue
elif any(line.startswith(kw) for kw in allowed_try_keywords):
@@ -1511,6 +1564,8 @@
def longest_line_length(code):
"""Return length of longest line."""
+ if len(code) == 0:
+ return 0
return max(len(line) for line in code.splitlines())
@@ -3648,6 +3703,10 @@
if apply_config:
parser = read_config(args, parser)
+ # prioritize settings when exist pyproject.toml's tool.autopep8 section
+ parser_with_pyproject_toml = read_pyproject_toml(args, parser)
+ if parser_with_pyproject_toml:
+ parser = parser_with_pyproject_toml
args = parser.parse_args(arguments)
args.files = [decode_filename(name) for name in args.files]
@@ -3722,15 +3781,23 @@
return args
+def _get_normalize_options(config, section, option_list):
+ for (k, _) in config.items(section):
+ norm_opt = k.lstrip('-').replace('-', '_')
+ if not option_list.get(norm_opt):
+ continue
+ opt_type = option_list[norm_opt]
+ if opt_type is int:
+ value = config.getint(section, k)
+ elif opt_type is bool:
+ value = config.getboolean(section, k)
+ else:
+ value = config.get(section, k)
+ yield norm_opt, k, value
+
+
def read_config(args, parser):
"""Read both user configuration and local configuration."""
- try:
- from configparser import ConfigParser as SafeConfigParser
- from configparser import Error
- except ImportError:
- from ConfigParser import SafeConfigParser
- from ConfigParser import Error
-
config = SafeConfigParser()
try:
@@ -3752,17 +3819,8 @@
for section in ['pep8', 'pycodestyle', 'flake8']:
if not config.has_section(section):
continue
- for (k, _) in config.items(section):
- norm_opt = k.lstrip('-').replace('-', '_')
- if not option_list.get(norm_opt):
- continue
- opt_type = option_list[norm_opt]
- if opt_type is int:
- value = config.getint(section, k)
- elif opt_type is bool:
- value = config.getboolean(section, k)
- else:
- value = config.get(section, k)
+ for norm_opt, k, value in _get_normalize_options(config, section,
+ option_list):
if args.verbose:
print("enable config: section={}, key={}, value={}".format(
section, k, value))
@@ -3775,6 +3833,44 @@
return parser
+
+def read_pyproject_toml(args, parser):
+ """Read pyproject.toml and load configuration."""
+ config = SafeConfigParser()
+
+ try:
+ config.read(args.global_config)
+
+ if not args.ignore_local_config:
+ parent = tail = args.files and os.path.abspath(
+ os.path.commonprefix(args.files))
+ while tail:
+ if config.read([os.path.join(parent, "pyproject.toml"), ]):
+ break
+ (parent, tail) = os.path.split(parent)
+
+ defaults = {}
+ option_list = {o.dest: o.type or type(o.default)
+ for o in parser._actions}
+
+ for section in ["tool.autopep8"]:
+ if not config.has_section(section):
+ continue
+ for norm_opt, k, value in _get_normalize_options(config, section,
+ option_list):
+ if args.verbose:
+ print("enable pyproject.toml config: section={}, "
+ "key={}, value={}".format(section, k, value))
+ defaults[norm_opt] = value
+
+ if defaults:
+ # set value when exists key-value in defaults dict
+ parser.set_defaults(**defaults)
+ except Error:
+ return None
+
+ return parser
+
def _split_comma_separated(string):
"""Return a set of strings."""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.4/setup.py new/autopep8-1.5/setup.py
--- old/autopep8-1.4.4/setup.py 2018-12-10 15:24:46.000000000 +0100
+++ new/autopep8-1.5/setup.py 2019-12-01 16:04:03.000000000 +0100
@@ -10,7 +10,7 @@
INSTALL_REQUIRES = (
- ['pycodestyle >= 2.4.0']
+ ['pycodestyle >= 2.5.0']
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.4/test/example_with_reduce.py
new/autopep8-1.5/test/example_with_reduce.py
--- old/autopep8-1.4.4/test/example_with_reduce.py 2018-08-14
17:07:08.000000000 +0200
+++ new/autopep8-1.5/test/example_with_reduce.py 2020-01-20
15:07:18.000000000 +0100
@@ -202,7 +202,7 @@
"""Distribution doesn't have an "extra feature" of the given name"""
_provider_factories = {}
-PY_MAJOR = sys.version[:3]
+PY_MAJOR = "{}.{}".format(*sys.version_info)
EGG_DIST = 3
BINARY_DIST = 2
SOURCE_DIST = 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.4/test/test_autopep8.py
new/autopep8-1.5/test/test_autopep8.py
--- old/autopep8-1.4.4/test/test_autopep8.py 2019-04-14 10:29:22.000000000
+0200
+++ new/autopep8-1.5/test/test_autopep8.py 2020-01-04 15:47:49.000000000
+0100
@@ -20,8 +20,7 @@
import io
import shutil
from subprocess import Popen, PIPE
-from tempfile import mkstemp
-import tempfile
+from tempfile import mkstemp, mkdtemp
import tokenize
import unittest
import warnings
@@ -455,7 +454,7 @@
msg=filename)
def test_find_files(self):
- temp_directory = tempfile.mkdtemp()
+ temp_directory = mkdtemp()
try:
target = os.path.join(temp_directory, 'dir')
os.mkdir(target)
@@ -615,7 +614,7 @@
contents='None == x\n')
self.assertEqual(
- [],
+ None,
fix_pep8.fix_e711({'line': 1,
'column': 6}))
@@ -852,6 +851,10 @@
re.sub(r'\s', '', text),
re.sub(r'\s', '', candidate))
+ def test_get_fixed_long_line_empty(self):
+ line = ''
+ self.assertEqual(line, autopep8.get_fixed_long_line(line, line, line))
+
class SystemTests(unittest.TestCase):
@@ -1025,8 +1028,8 @@
"""
fixed = """\
while True: # My inline comment
- # with a hanging
- # comment.
+ # with a hanging
+ # comment.
# Hello
if True:
# My comment
@@ -1229,6 +1232,22 @@
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
+ def test_e117(self):
+ line = """\
+for a in [1, 2, 3]:
+ print('hello world')
+ for b in [1, 2, 3]:
+ print(a, b)
+"""
+ fixed = """\
+for a in [1, 2, 3]:
+ print('hello world')
+ for b in [1, 2, 3]:
+ print(a, b)
+"""
+ with autopep8_context(line) as result:
+ self.assertEqual(fixed, result)
+
def test_e12_reindent(self):
line = """\
def foo_bar(baz, frop,
@@ -2422,6 +2441,56 @@
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
+ def test_e401_with_multiline_from_import(self):
+ line = """\
+from os import (
+ chroot
+)
+def f():
+ pass
+from a import b
+from b import c
+from c import d
+"""
+ fixed = """\
+from a import b
+from c import d
+from b import c
+from os import (
+ chroot
+)
+
+
+def f():
+ pass
+"""
+ with autopep8_context(line) as result:
+ self.assertEqual(fixed, result)
+
+ def test_e402_with_multiline_from_future_import(self):
+ line = """\
+from __future__ import (
+ absolute_import,
+ print_function
+)
+def f():
+ pass
+import os
+"""
+ fixed = """\
+from __future__ import (
+ absolute_import,
+ print_function
+)
+import os
+
+
+def f():
+ pass
+"""
+ with autopep8_context(line) as result:
+ self.assertEqual(fixed, result)
+
def test_e402_with_module_doc(self):
line1 = '"""\nmodule doc\n"""\na = 1\nimport os\n'
fixed1 = '"""\nmodule doc\n"""\nimport os\na = 1\n'
@@ -3939,9 +4008,14 @@
with autopep8_context(line, options=['--aggressive']) as result:
self.assertEqual(fixed, result)
+ line = 'None == foo\n'
+ fixed = 'None is foo\n'
+ with autopep8_context(line, options=['--aggressive']) as result:
+ self.assertEqual(fixed, result)
+
def test_e711_in_conditional(self):
line = 'if foo == None and None == foo:\npass\n'
- fixed = 'if foo is None and None == foo:\npass\n'
+ fixed = 'if foo is None and None is foo:\npass\n'
with autopep8_context(line, options=['--aggressive']) as result:
self.assertEqual(fixed, result)
@@ -4381,6 +4455,22 @@
with autopep8_context(line, options=['--select=W503']) as result:
self.assertEqual(fixed, result)
+ def test_w503_with_comment_with_only_comment_block_charactor(self):
+ line = """\
+if (True #
+ and True
+ and True):
+ print(1)
+"""
+ fixed = """\
+if (True and #
+ True and
+ True):
+ print(1)
+"""
+ with autopep8_context(line, options=['--select=W503']) as result:
+ self.assertEqual(fixed, result)
+
def test_w503_over_5lines(self):
line = """\
X = (
@@ -4809,6 +4899,12 @@
with autopep8_context(line, options=['--aggressive', '--pep8-passes',
'5']) as result:
self.assertEqual(fixed, result)
+ def test_w605_with_invalid_syntax(self):
+ line = "escape = rr'\\.jpg'\n"
+ fixed = "escape = rr'\\.jpg'\n"
+ with autopep8_context(line, options=['--aggressive']) as result:
+ self.assertEqual(fixed, result)
+
def test_trailing_whitespace_in_multiline_string(self):
line = 'x = """ \nhello""" \n'
fixed = 'x = """ \nhello"""\n'
@@ -4877,6 +4973,31 @@
with autopep8_context(line, options=['--line-range', '1', '1']) as
result:
self.assertEqual(line, result)
+ def test_long_import_line(self):
+ line = """\
+s
+from t import a, \
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc,
ddddddddddddddddddddddddddddddddddd
+"""
+ fixed = """\
+from t import a, \
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc,
ddddddddddddddddddddddddddddddddddd
+s
+"""
+ with autopep8_context(line) as result:
+ self.assertEqual(fixed, result)
+
+ def test_exchange_multiple_imports_with_def(self):
+ line = """\
+def f(n):
+ return n
+from a import fa
+from b import fb
+from c import fc
+"""
+ with autopep8_context(line) as result:
+ self.assertEqual(result[:4], 'from')
+
class UtilityFunctionTests(unittest.TestCase):
@@ -5104,7 +5225,7 @@
self.assertIn('--in-place and --diff are mutually exclusive', result)
def test_recursive(self):
- temp_directory = tempfile.mkdtemp(dir='.')
+ temp_directory = mkdtemp(dir='.')
try:
with open(os.path.join(temp_directory, 'a.py'), 'w') as output:
output.write("'abc' \n")
@@ -5130,7 +5251,7 @@
shutil.rmtree(temp_directory)
def test_recursive_should_not_crash_on_unicode_filename(self):
- temp_directory = tempfile.mkdtemp(dir='.')
+ temp_directory = mkdtemp(dir='.')
try:
for filename in ['x.py', 'é.py', 'é.txt']:
with open(os.path.join(temp_directory, filename), 'w'):
@@ -5147,8 +5268,8 @@
shutil.rmtree(temp_directory)
def test_recursive_should_ignore_hidden(self):
- temp_directory = tempfile.mkdtemp(dir='.')
- temp_subdirectory = tempfile.mkdtemp(prefix='.', dir=temp_directory)
+ temp_directory = mkdtemp(dir='.')
+ temp_subdirectory = mkdtemp(prefix='.', dir=temp_directory)
try:
with open(os.path.join(temp_subdirectory, 'a.py'), 'w') as output:
output.write("'abc' \n")
@@ -5164,7 +5285,7 @@
shutil.rmtree(temp_directory)
def test_exclude(self):
- temp_directory = tempfile.mkdtemp(dir='.')
+ temp_directory = mkdtemp(dir='.')
try:
with open(os.path.join(temp_directory, 'a.py'), 'w') as output:
output.write("'abc' \n")
@@ -5356,6 +5477,51 @@
apply_config=True)
self.assertEqual(args.aggressive, 1)
+ def test_pyproject_toml_config_local_int_value(self):
+ with temporary_file_context('[tool.autopep8]\naggressive=2\n') as
filename:
+ args = autopep8.parse_args(
+ [os.path.join(FAKE_CONFIGURATION, 'foo.py'),
+ '--global-config={}'.format(filename)],
+ apply_config=True)
+ self.assertEqual(args.aggressive, 2)
+
+
+class ConfigurationFileTests(unittest.TestCase):
+
+ def test_pyproject_toml_with_flake8_config(self):
+ """override to flake8 config"""
+ line = "a = 1\n"
+ dot_flake8 = """[pep8]\naggressive=0\n"""
+ pyproject_toml = """[tool.autopep8]\naggressvie=2\nignore=E,W\n"""
+ with temporary_project_directory() as dirname:
+ with open(os.path.join(dirname, "pyproject.toml"), "w") as fp:
+ fp.write(pyproject_toml)
+ with open(os.path.join(dirname, ".flake8"), "w") as fp:
+ fp.write(dot_flake8)
+ target_filename = os.path.join(dirname, "foo.py")
+ with open(target_filename, "w") as fp:
+ fp.write(line)
+ p = Popen(list(AUTOPEP8_CMD_TUPLE) + [target_filename],
stdout=PIPE)
+ self.assertEqual(p.communicate()[0].decode("utf-8"), line)
+ self.assertEqual(p.returncode, 0)
+
+ def test_pyproject_toml_with_verbose_option(self):
+ """override to flake8 config"""
+ line = "a = 1\n"
+ verbose_line = "enable pyproject.toml config: section=tool.autopep8,
key=ignore, value=E,W\n"
+ pyproject_toml = """[tool.autopep8]\naggressvie=2\nignore=E,W\n"""
+ with temporary_project_directory() as dirname:
+ with open(os.path.join(dirname, "pyproject.toml"), "w") as fp:
+ fp.write(pyproject_toml)
+ target_filename = os.path.join(dirname, "foo.py")
+ with open(target_filename, "w") as fp:
+ fp.write(line)
+ p = Popen(list(AUTOPEP8_CMD_TUPLE) + [target_filename, "-vvv"],
stdout=PIPE)
+ output = p.communicate()[0].decode("utf-8")
+ self.assertTrue(line in output)
+ self.assertTrue(verbose_line in output)
+ self.assertEqual(p.returncode, 0)
+
class ExperimentalSystemTests(unittest.TestCase):
@@ -6656,6 +6822,13 @@
@contextlib.contextmanager
+def temporary_project_directory(prefix="autopep8test"):
+ temporary = mkdtemp(prefix=prefix)
+ yield temporary
+ shutil.rmtree(temporary)
+
+
[email protected]
def disable_stderr():
sio = StringIO()
with capture_stderr(sio):