diff options
| author | Timothy Crosley <timothy.crosley@gmail.com> | 2021-08-06 23:22:21 -0700 |
|---|---|---|
| committer | Timothy Crosley <timothy.crosley@gmail.com> | 2021-08-06 23:22:21 -0700 |
| commit | c29c6d6c0eaa9ed987157593822e501e89ca02b1 (patch) | |
| tree | 6120ce8b61edda6e0d888421b819feeaecb97533 /tests/unit | |
| parent | 3a571463b12f4588533b4c0e2a6760f665d33ac6 (diff) | |
| download | isort-c29c6d6c0eaa9ed987157593822e501e89ca02b1.tar.gz | |
Add test case for issue #1799
Diffstat (limited to 'tests/unit')
| -rw-r--r-- | tests/unit/test_regressions.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/test_regressions.py b/tests/unit/test_regressions.py index 1853893e..d1003e21 100644 --- a/tests/unit/test_regressions.py +++ b/tests/unit/test_regressions.py @@ -1869,3 +1869,33 @@ class Bar: ... ''' ) + + +def test_isort_should_produce_the_same_code_on_subsequent_runs_issue_1799(tmpdir): + code = """import sys + +if sys.version_info[:2] >= (3, 8): + # TODO: Import directly (no need for conditional) when `python_requires = >= 3.8` + from importlib.metadata import PackageNotFoundError, version # pragma: no cover +else: + from importlib_metadata import PackageNotFoundError, version # pragma: no cover +""" + config_file = tmpdir.join(".isort.cfg") + config_file.write( + """[isort] +profile=black +src_paths=isort,test +line_length=100 +skip=.tox,.venv,build,dist,docs,tests +extra_standard_library=pkg_resources,setuptools,typing +known_test=pytest +known_first_party=ibpt +sections=FUTURE,STDLIB,TEST,THIRDPARTY,FIRSTPARTY,LOCALFOLDER +import_heading_firstparty=internal +import_heading_thirdparty=external +""" + ) + settings = isort.settings.Config(str(config_file)) + assert isort.code(code, config=settings) == isort.code( + isort.code(code, config=settings), config=settings + ) |
