Hello community, here is the log from the commit of package python-isort for openSUSE:Factory checked in at 2019-03-08 11:59:54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-isort (Old) and /work/SRC/openSUSE:Factory/.python-isort.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-isort" Fri Mar 8 11:59:54 2019 rev:8 rq:681407 version:4.3.10 Changes: -------- --- /work/SRC/openSUSE:Factory/python-isort/python-isort.changes 2019-03-04 13:45:23.090685340 +0100 +++ /work/SRC/openSUSE:Factory/.python-isort.new.28833/python-isort.changes 2019-03-08 11:59:57.927969486 +0100 @@ -1,0 +2,12 @@ +Mon Mar 4 13:25:15 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 4.3.10: + * Fixed Windows incompatibilities (Issue #835) + * Fixed relative import sorting bug (Issue #417) + * Fixed "no_lines_before" to also be respected from previous empty sections. + * Fixed slow-down introduced by finders mechanism by adding a LRU cache (issue #848) + * Fixed issue #842 default encoding not-set in Python2 + * Restored Windows automated testing + * Added Mac automated testing + +------------------------------------------------------------------- Old: ---- isort-4.3.9.tar.gz New: ---- isort-4.3.10.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-isort.spec ++++++ --- /var/tmp/diff_new_pack.tCIxCw/_old 2019-03-08 11:59:58.507969388 +0100 +++ /var/tmp/diff_new_pack.tCIxCw/_new 2019-03-08 11:59:58.511969387 +0100 @@ -26,7 +26,7 @@ %bcond_with test %endif Name: python-isort%{psuffix} -Version: 4.3.9 +Version: 4.3.10 Release: 0 Summary: A Python utility / library to sort Python imports License: MIT @@ -37,13 +37,15 @@ BuildRequires: %{python_module mock} BuildRequires: %{python_module pylama} BuildRequires: %{python_module pytest} +BuildRequires: python-backports.functools_lru_cache %endif BuildRequires: %{python_module setuptools} BuildRequires: fdupes +BuildRequires: python-futures BuildRequires: python-rpm-macros -BuildRequires: python2-futures BuildArch: noarch %ifpython2 +Requires: python-backports.functools_lru_cache Requires: python-futures %endif %python_subpackages ++++++ isort-4.3.9.tar.gz -> isort-4.3.10.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/CHANGELOG.md new/isort-4.3.10/CHANGELOG.md --- old/isort-4.3.9/CHANGELOG.md 2019-02-25 23:33:56.000000000 +0100 +++ new/isort-4.3.10/CHANGELOG.md 2019-03-03 05:53:49.000000000 +0100 @@ -1,9 +1,18 @@ Changelog ========= -### 4.3.9 - Feburary 25, 2019 - hot fix release +### 4.3.10 - March 2, 2019 - hot fix release +- Fixed Windows incompatibilities (Issue #835) +- Fixed relative import sorting bug (Issue #417) +- Fixed "no_lines_before" to also be respected from previous empty sections. +- Fixed slow-down introduced by finders mechanism by adding a LRU cache (issue #848) +- Fixed issue #842 default encoding not-set in Python2 +- Restored Windows automated testing +- Added Mac automated testing + +### 4.3.9 - February 25, 2019 - hot fix release - Fixed a bug that led to an incompatibility with black: #831 -### 4.3.8 - Feburary 25, 2019 - hot fix release +### 4.3.8 - February 25, 2019 - hot fix release - Fixed a bug that led to the recursive option not always been available from the command line. ### 4.3.7 - February 25, 2019 - hot fix release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/PKG-INFO new/isort-4.3.10/PKG-INFO --- old/isort-4.3.9/PKG-INFO 2019-02-25 23:36:17.000000000 +0100 +++ new/isort-4.3.10/PKG-INFO 2019-03-03 06:07:06.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: isort -Version: 4.3.9 +Version: 4.3.10 Summary: A Python utility / library to sort Python imports. Home-page: https://github.com/timothycrosley/isort Author: Timothy Crosley diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort/__init__.py new/isort-4.3.10/isort/__init__.py --- old/isort-4.3.9/isort/__init__.py 2019-02-25 23:34:58.000000000 +0100 +++ new/isort-4.3.10/isort/__init__.py 2019-03-03 06:02:41.000000000 +0100 @@ -25,4 +25,4 @@ from . import settings # noqa: F401 from .isort import SortImports # noqa: F401 -__version__ = "4.3.9" +__version__ = "4.3.10" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort/__main__.py new/isort-4.3.10/isort/__main__.py --- old/isort-4.3.9/isort/__main__.py 2019-02-25 23:26:59.000000000 +0100 +++ new/isort-4.3.10/isort/__main__.py 2019-03-03 05:53:36.000000000 +0100 @@ -1,5 +1,9 @@ from __future__ import absolute_import -from isort.main import main +from isort.pie_slice import apply_changes_to_python_environment + +apply_changes_to_python_environment() + +from isort.main import main # noqa: E402 isort:skip main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort/finders.py new/isort-4.3.10/isort/finders.py --- old/isort-4.3.9/isort/finders.py 2019-02-25 23:26:59.000000000 +0100 +++ new/isort-4.3.10/isort/finders.py 2019-03-03 05:53:36.000000000 +0100 @@ -35,6 +35,11 @@ except ImportError: Pipfile = None +try: + from functools import lru_cache +except ImportError: + from backports.functools_lru_cache import lru_cache + KNOWN_SECTION_MAPPING = { 'STDLIB': 'STANDARD_LIBRARY', @@ -260,6 +265,13 @@ def _get_files_from_dir(self, path): """Return paths to requirements files from passed dir. """ + return RequirementsFinder._get_files_from_dir_cached(path) + + @classmethod + @lru_cache(maxsize=16) + def _get_files_from_dir_cached(cls, path): + result = [] + for fname in os.listdir(path): if 'requirements' not in fname: continue @@ -268,18 +280,20 @@ # *requirements*/*.{txt,in} if os.path.isdir(full_path): for subfile_name in os.listdir(path): - for ext in self.exts: + for ext in cls.exts: if subfile_name.endswith(ext): - yield os.path.join(path, subfile_name) + result.append(os.path.join(path, subfile_name)) continue # *requirements*.{txt,in} if os.path.isfile(full_path): - for ext in self.exts: + for ext in cls.exts: if fname.endswith(ext): - yield full_path + result.append(full_path) break + return result + def _get_names(self, path): """Load required packages from path to requirements file """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort/isort.py new/isort-4.3.10/isort/isort.py --- old/isort-4.3.9/isort/isort.py 2019-02-25 23:30:23.000000000 +0100 +++ new/isort-4.3.10/isort/isort.py 2019-03-03 05:53:36.000000000 +0100 @@ -255,13 +255,10 @@ @staticmethod def _module_key(module_name, config, sub_imports=False, ignore_case=False, section_name=None): - dots = 0 - while module_name.startswith('.'): - dots += 1 - module_name = module_name[1:] - - if dots: - module_name = '{} {}'.format(('.' * dots), module_name) + match = re.match(r'^(\.+)\s*(.*)', module_name) + if match: + sep = ' ' if config['reverse_relative'] else '_' + module_name = sep.join(match.groups()) prefix = "" if ignore_case: @@ -525,7 +522,7 @@ sections = ('no_sections', ) output = [] - prev_section_has_imports = False + pending_lines_before = False for section in sections: straight_modules = self.imports[section]['straight'] straight_modules = nsorted(straight_modules, key=lambda key: self._module_key(key, self.config, section_name=section)) @@ -558,8 +555,11 @@ line = line.lower() return '{0}{1}'.format(section, line) section_output = nsorted(section_output, key=by_module) + + section_name = section + no_lines_before = section_name in self.config['no_lines_before'] + if section_output: - section_name = section if section_name in self.place_imports: self.place_imports[section_name] = section_output continue @@ -569,11 +569,16 @@ section_comment = "# {0}".format(section_title) if section_comment not in self.out_lines[0:1] and section_comment not in self.in_lines[0:1]: section_output.insert(0, section_comment) - if prev_section_has_imports and section_name in self.config['no_lines_before']: - while output and output[-1].strip() == '': - output.pop() - output += section_output + ([''] * self.config['lines_between_sections']) - prev_section_has_imports = bool(section_output) + + if pending_lines_before or not no_lines_before: + output += ([''] * self.config['lines_between_sections']) + + output += section_output + + pending_lines_before = False + else: + pending_lines_before = pending_lines_before or not no_lines_before + while output and output[-1].strip() == '': output.pop() while output and output[0].strip() == '': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort/main.py new/isort-4.3.10/isort/main.py --- old/isort-4.3.9/isort/main.py 2019-02-25 23:26:59.000000000 +0100 +++ new/isort-4.3.10/isort/main.py 2019-03-03 05:53:36.000000000 +0100 @@ -254,6 +254,8 @@ parser.add_argument('-r', dest='ambiguous_r_flag', action='store_true') parser.add_argument('-rm', '--remove-import', dest='remove_imports', action='append', help='Removes the specified import from all files.') + parser.add_argument('-rr', '--reverse-relative', dest='reverse_relative', action='store_true', + help='Reverse order of relative imports.') parser.add_argument('-rc', '--recursive', dest='recursive', action='store_true', help='Recursively look for Python files of which to sort imports') parser.add_argument('-s', '--skip', help='Files that sort imports should skip over. If you want to skip multiple ' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort/pie_slice.py new/isort-4.3.10/isort/pie_slice.py --- old/isort-4.3.9/isort/pie_slice.py 2019-02-25 23:26:59.000000000 +0100 +++ new/isort-4.3.10/isort/pie_slice.py 2019-03-03 05:53:36.000000000 +0100 @@ -30,14 +30,39 @@ PY3 = sys.version_info[0] == 3 VERSION = sys.version_info -__all__ = ['PY2', 'PY3', 'lru_cache'] +__all__ = ['PY2', 'PY3', 'lru_cache', 'apply_changes_to_python_environment'] if PY3: input = input + + def apply_changes_to_python_environment(): + pass else: input = raw_input # noqa: F821 + python_environment_changes_applied = False + + import sys + stdout = sys.stdout + stderr = sys.stderr + + def apply_changes_to_python_environment(): + global python_environment_changes_applied + if python_environment_changes_applied or sys.getdefaultencoding() == 'utf-8': + python_environment_changes_applied = True + return + + try: + reload(sys) + sys.stdout = stdout + sys.stderr = stderr + sys.setdefaultencoding('utf-8') + except NameError: # Python 3 + sys.exit('This should not happen!') + + python_environment_changes_applied = True + if sys.version_info < (3, 2): try: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort/settings.py new/isort-4.3.10/isort/settings.py --- old/isort-4.3.9/isort/settings.py 2019-02-25 23:26:59.000000000 +0100 +++ new/isort-4.3.10/isort/settings.py 2019-03-03 05:53:36.000000000 +0100 @@ -29,7 +29,6 @@ import os import posixpath import re -import stat import sys import warnings from collections import namedtuple @@ -130,6 +129,7 @@ 'length_sort': False, 'add_imports': [], 'remove_imports': [], + 'reverse_relative': False, 'force_single_line': False, 'default_section': 'FIRSTPARTY', 'import_heading_future': '', @@ -288,7 +288,7 @@ settings.update(config_section) else: warnings.warn( - "Found %s but toml package is not installed. To configure" + "Found %s but toml package is not installed. To configure " "isort with %s, install with 'isort[pyproject]'." % (file_path, file_path) ) else: @@ -316,9 +316,12 @@ return settings -def should_skip(filename, config, path='/'): +def should_skip(filename, config, path=''): """Returns True if the file should be skipped based on the passed in settings.""" - normalized_path = posixpath.join(path.replace('\\', '/'), filename) + os_path = os.path.join(path, filename) + normalized_path = os_path.replace('\\', '/') + if normalized_path[1:2] == ':': + normalized_path = normalized_path[2:] if config['safety_excludes'] and safety_exclude_re.search(normalized_path): return True @@ -337,7 +340,7 @@ if fnmatch.fnmatch(filename, glob): return True - if stat.S_ISFIFO(os.stat(normalized_path).st_mode): + if not (os.path.isfile(os_path) or os.path.isdir(os_path) or os.path.islink(os_path)): return True return False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort.egg-info/PKG-INFO new/isort-4.3.10/isort.egg-info/PKG-INFO --- old/isort-4.3.9/isort.egg-info/PKG-INFO 2019-02-25 23:36:17.000000000 +0100 +++ new/isort-4.3.10/isort.egg-info/PKG-INFO 2019-03-03 06:07:06.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: isort -Version: 4.3.9 +Version: 4.3.10 Summary: A Python utility / library to sort Python imports. Home-page: https://github.com/timothycrosley/isort Author: Timothy Crosley diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/isort.egg-info/requires.txt new/isort-4.3.10/isort.egg-info/requires.txt --- old/isort-4.3.9/isort.egg-info/requires.txt 2019-02-25 23:36:17.000000000 +0100 +++ new/isort-4.3.10/isort.egg-info/requires.txt 2019-03-03 06:07:06.000000000 +0100 @@ -1,5 +1,6 @@ [:python_version < "3.2"] +backports.functools_lru_cache futures [pipfile] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/setup.py new/isort-4.3.10/setup.py --- old/isort-4.3.9/setup.py 2019-02-25 23:34:07.000000000 +0100 +++ new/isort-4.3.10/setup.py 2019-03-03 06:02:48.000000000 +0100 @@ -6,7 +6,7 @@ readme = f.read() setup(name='isort', - version='4.3.9', + version='4.3.10', description='A Python utility / library to sort Python imports.', long_description=readme, author='Timothy Crosley', @@ -27,7 +27,10 @@ 'requirements': ['pip', 'pipreqs'], 'xdg_home': ['appdirs'], }, - install_requires=['futures; python_version < "3.2"'], + install_requires=[ + 'futures; python_version < "3.2"', + 'backports.functools_lru_cache; python_version < "3.2"', + ], python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", keywords='Refactor, Python, Python2, Python3, Refactoring, Imports, Sort, Clean', classifiers=['Development Status :: 6 - Mature', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.9/test_isort.py new/isort-4.3.10/test_isort.py --- old/isort-4.3.9/test_isort.py 2019-02-25 23:30:14.000000000 +0100 +++ new/isort-4.3.10/test_isort.py 2019-03-03 05:53:36.000000000 +0100 @@ -27,6 +27,7 @@ import io import os import os.path +import posixpath import sys import sysconfig @@ -55,7 +56,6 @@ balanced_wrapping = true not_skip = __init__.py """ - SHORT_IMPORT = "from third_party import lib1, lib2, lib3, lib4" SINGLE_FROM_IMPORT = "from third_party import lib1" SINGLE_LINE_LONG_IMPORT = "from third_party import lib1, lib2, lib3, lib4, lib5, lib5ab" @@ -72,8 +72,9 @@ config_file = config_dir.join('.editorconfig').strpath with open(config_file, 'w') as editorconfig: editorconfig.write(TEST_DEFAULT_CONFIG) - os.chdir(config_dir.strpath) - return config_dir.strpath + + with config_dir.as_cwd(): + yield config_dir.strpath def test_happy_path(): @@ -569,7 +570,7 @@ test_input = ("import django\n" "import myproject\n") - sort_imports = SortImports(file_path='/baz.py', file_contents=test_input, known_third_party=['django'], + sort_imports = SortImports(file_path='/baz.py', file_contents=test_input, settings_path=os.getcwd(), skip=['baz.py']) assert sort_imports.skipped assert sort_imports.output is None @@ -1725,7 +1726,7 @@ tmp_fname = tmpdir.join('test_{0}.py'.format(encoding)) file_contents = "# coding: {0}\n\ns = u'ã'\n".format(encoding) tmp_fname.write_binary(file_contents.encode(encoding)) - assert SortImports(file_path=str(tmp_fname)).output == file_contents + assert SortImports(file_path=str(tmp_fname), settings_path=os.getcwd()).output == file_contents def test_comment_at_top_of_file(): @@ -2241,7 +2242,8 @@ """Test to ensure Python 2 and 3 have the same behavior""" test_input = ('from future.standard_library import hooks\n' 'from workalendar.europe import UnitedKingdom\n') - assert SortImports(file_contents=test_input).output == test_input + assert SortImports(file_contents=test_input, + known_first_party=["future"]).output == test_input def test_sort_within_section_comments_issue_436(): @@ -2391,6 +2393,18 @@ assert SortImports(file_contents=test_input, no_lines_before=['STDLIB']).output == test_input +def test_no_lines_before_empty_section(): + test_input = ('import first\n' + 'import custom\n') + assert SortImports( + file_contents=test_input, + known_third_party=["first"], + known_custom=["custom"], + sections=['THIRDPARTY', 'LOCALFOLDER', 'CUSTOM'], + no_lines_before=['THIRDPARTY', 'LOCALFOLDER', 'CUSTOM'], + ).output == test_input + + def test_no_inline_sort(): """Test to ensure multiple `from` imports in one line are not sorted if `--no-inline-sort` flag is enabled. If `--force-single-line-imports` flag is enabled, then `--no-inline-sort` is ignored.""" @@ -2513,32 +2527,49 @@ def test_new_lines_are_preserved(): - with NamedTemporaryFile('w', suffix='py') as rn_newline: + with NamedTemporaryFile('w', suffix='py', delete=False) as rn_newline: + pass + + try: with io.open(rn_newline.name, mode='w', newline='') as rn_newline_input: rn_newline_input.write('import sys\r\nimport os\r\n') - rn_newline_input.flush() - SortImports(rn_newline.name) - with io.open(rn_newline.name, newline='') as rn_newline_file: - rn_newline_contents = rn_newline_file.read() - assert rn_newline_contents == 'import os\r\nimport sys\r\n' - with NamedTemporaryFile('w', suffix='py') as r_newline: + SortImports(rn_newline.name, settings_path=os.getcwd()) + with io.open(rn_newline.name) as new_line_file: + print(new_line_file.read()) + with io.open(rn_newline.name, newline='') as rn_newline_file: + rn_newline_contents = rn_newline_file.read() + assert rn_newline_contents == 'import os\r\nimport sys\r\n' + finally: + os.remove(rn_newline.name) + + with NamedTemporaryFile('w', suffix='py', delete=False) as r_newline: + pass + + try: with io.open(r_newline.name, mode='w', newline='') as r_newline_input: r_newline_input.write('import sys\rimport os\r') - r_newline_input.flush() - SortImports(r_newline.name) - with io.open(r_newline.name, newline='') as r_newline_file: - r_newline_contents = r_newline_file.read() - assert r_newline_contents == 'import os\rimport sys\r' - with NamedTemporaryFile('w', suffix='py') as n_newline: + SortImports(r_newline.name, settings_path=os.getcwd()) + with io.open(r_newline.name, newline='') as r_newline_file: + r_newline_contents = r_newline_file.read() + assert r_newline_contents == 'import os\rimport sys\r' + finally: + os.remove(r_newline.name) + + with NamedTemporaryFile('w', suffix='py', delete=False) as n_newline: + pass + + try: with io.open(n_newline.name, mode='w', newline='') as n_newline_input: n_newline_input.write('import sys\nimport os\n') - n_newline_input.flush() - SortImports(n_newline.name) - with io.open(n_newline.name, newline='') as n_newline_file: - n_newline_contents = n_newline_file.read() - assert n_newline_contents == 'import os\nimport sys\n' + + SortImports(n_newline.name, settings_path=os.getcwd()) + with io.open(n_newline.name, newline='') as n_newline_file: + n_newline_contents = n_newline_file.read() + assert n_newline_contents == 'import os\nimport sys\n' + finally: + os.remove(n_newline.name) @pytest.mark.skipif(not finders.RequirementsFinder.enabled, reason='RequirementsFinder not enabled (too old version of pip?)') @@ -2664,11 +2695,11 @@ third_party_prefix = next(path for path in finder.paths if "site-packages" in path) ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so" imaginary_paths = set([ - os.path.join(finder.stdlib_lib_prefix, "example_1.py"), - os.path.join(third_party_prefix, "example_2.py"), - os.path.join(third_party_prefix, "example_3.so"), - os.path.join(third_party_prefix, "example_4" + ext_suffix), - os.path.join(os.getcwd(), "example_5.py"), + posixpath.join(finder.stdlib_lib_prefix, "example_1.py"), + posixpath.join(third_party_prefix, "example_2.py"), + posixpath.join(third_party_prefix, "example_3.so"), + posixpath.join(third_party_prefix, "example_4" + ext_suffix), + posixpath.join(os.getcwd(), "example_5.py"), ]) monkeypatch.setattr("isort.finders.exists_case_sensitive", lambda p: p in imaginary_paths) assert finder.find("example_1") == finder.sections.STDLIB @@ -2692,17 +2723,18 @@ from isort.main import main tmpdir.join("file1.py").write("import re\nimport os\n\nimport contextlib\n\n\nimport isort") tmpdir.join("file2.py").write("import collections\nimport time\n\nimport abc\n\n\nimport isort") - arguments = ["-rc", str(tmpdir)] + arguments = ["-rc", str(tmpdir), '--settings-path', os.getcwd()] if multiprocess: arguments.extend(['--jobs', '2']) main(arguments) assert tmpdir.join("file1.py").read() == "import contextlib\nimport os\nimport re\n\nimport isort\n" assert tmpdir.join("file2.py").read() == "import abc\nimport collections\nimport time\n\nimport isort\n" - out, err = capfd.readouterr() - assert not err - # it informs us about fixing the files: - assert str(tmpdir.join("file1.py")) in out - assert str(tmpdir.join("file2.py")) in out + if not sys.platform.startswith('win'): + out, err = capfd.readouterr() + assert not err + # it informs us about fixing the files: + assert str(tmpdir.join("file1.py")) in out + assert str(tmpdir.join("file2.py")) in out @pytest.mark.parametrize('enabled', (False, True)) @@ -2712,12 +2744,15 @@ tmpdir.mkdir("lib").mkdir("python3.7").join("importantsystemlibrary.py").write("# ...") config = dict(settings.default.copy(), safety_excludes=enabled) skipped = [] + codes = [str(tmpdir)], + main.iter_source_code(codes, config, skipped) file_names = set(os.path.relpath(f, str(tmpdir)) for f in main.iter_source_code([str(tmpdir)], config, skipped)) if enabled: assert file_names == {'victim.py'} assert len(skipped) == 2 else: - assert file_names == {'.tox/verysafe.py', 'lib/python3.7/importantsystemlibrary.py', 'victim.py'} + assert file_names == {os.sep.join(('.tox', 'verysafe.py')), + os.sep.join(('lib', 'python3.7', 'importantsystemlibrary.py')), 'victim.py'} assert not skipped @@ -2728,7 +2763,7 @@ assert SortImports(file_contents=test_input).output == test_input -def test_inconsistent_relative_imports_issue_577(): +def test_reverse_relative_imports_issue_417(): test_input = ('from . import ipsum\n' 'from . import lorem\n' 'from .dolor import consecteur\n' @@ -2741,6 +2776,24 @@ 'from ... import dui\n' 'from ...eu import dignissim\n' 'from ...ex import metus\n') + assert SortImports(file_contents=test_input, + force_single_line=True, + reverse_relative=True).output == test_input + + +def test_inconsistent_relative_imports_issue_577(): + test_input = ('from ... import diam\n' + 'from ... import dui\n' + 'from ...eu import dignissim\n' + 'from ...ex import metus\n' + 'from .. import donec\n' + 'from .. import euismod\n' + 'from ..mi import iaculis\n' + 'from ..nec import tempor\n' + 'from . import ipsum\n' + 'from . import lorem\n' + 'from .dolor import consecteur\n' + 'from .sit import apidiscing\n') assert SortImports(file_contents=test_input, force_single_line=True).output == test_input
