diff options
-rw-r--r-- | tests/integration/conftest.py | 64 | ||||
-rw-r--r-- | tests/integration/test_setting_combinations.py | 61 |
2 files changed, 61 insertions, 64 deletions
diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py deleted file mode 100644 index 0e9a315a..00000000 --- a/tests/integration/conftest.py +++ /dev/null @@ -1,64 +0,0 @@ -from typing import get_type_hints - -from hypothesis import strategies as st - -import isort - - -def _as_config(kw) -> isort.Config: - kw["atomic"] = False - if "wrap_length" in kw and "line_length" in kw: - kw["wrap_length"], kw["line_length"] = sorted([kw["wrap_length"], kw["line_length"]]) - try: - return isort.Config(**kw) - except ValueError: - kw["wrap_length"] = 0 - return isort.Config(**kw) - - -def configs() -> st.SearchStrategy[isort.Config]: - """Generate arbitrary Config objects.""" - skip = { - "line_ending", - "sections", - "known_standard_library", - "known_future_library", - "known_third_party", - "known_first_party", - "known_local_folder", - "extra_standard_library", - "forced_separate", - "lines_after_imports", - "add_imports", - "lines_between_sections", - "lines_between_types", - "sources", - "virtual_env", - "conda_env", - "directory", - "formatter", - "formatting_function", - "comment_prefix", - "atomic", - "skip", - "src_paths", - } - inferred_kwargs = { - k: st.from_type(v) - for k, v in get_type_hints(isort.settings._Config).items() - if k not in skip - } - specific = { - "line_length": st.integers(0, 200), - "wrap_length": st.integers(0, 200), - "indent": st.integers(0, 20).map(lambda n: n * " "), - "default_section": st.sampled_from(sorted(isort.settings.KNOWN_SECTION_MAPPING)), - "force_grid_wrap": st.integers(0, 20), - "profile": st.sampled_from(sorted(isort.settings.profiles)), - "py_version": st.sampled_from(("auto",) + isort.settings.VALID_PY_TARGETS), - } - kwargs = {**inferred_kwargs, **specific} - return st.fixed_dictionaries({}, optional=kwargs).map(_as_config) - - -st.register_type_strategy(isort.Config, configs()) diff --git a/tests/integration/test_setting_combinations.py b/tests/integration/test_setting_combinations.py index 591bcc4d..c29c7742 100644 --- a/tests/integration/test_setting_combinations.py +++ b/tests/integration/test_setting_combinations.py @@ -1,8 +1,69 @@ +from typing import get_type_hints + import hypothesis from hypothesis import strategies as st import isort + +def _as_config(kw) -> isort.Config: + kw["atomic"] = False + if "wrap_length" in kw and "line_length" in kw: + kw["wrap_length"], kw["line_length"] = sorted([kw["wrap_length"], kw["line_length"]]) + try: + return isort.Config(**kw) + except ValueError: + kw["wrap_length"] = 0 + return isort.Config(**kw) + + +def configs() -> st.SearchStrategy[isort.Config]: + """Generate arbitrary Config objects.""" + skip = { + "line_ending", + "sections", + "known_standard_library", + "known_future_library", + "known_third_party", + "known_first_party", + "known_local_folder", + "extra_standard_library", + "forced_separate", + "lines_after_imports", + "add_imports", + "lines_between_sections", + "lines_between_types", + "sources", + "virtual_env", + "conda_env", + "directory", + "formatter", + "formatting_function", + "comment_prefix", + "atomic", + "skip", + "src_paths", + } + inferred_kwargs = { + k: st.from_type(v) + for k, v in get_type_hints(isort.settings._Config).items() + if k not in skip + } + specific = { + "line_length": st.integers(0, 200), + "wrap_length": st.integers(0, 200), + "indent": st.integers(0, 20).map(lambda n: n * " "), + "default_section": st.sampled_from(sorted(isort.settings.KNOWN_SECTION_MAPPING)), + "force_grid_wrap": st.integers(0, 20), + "profile": st.sampled_from(sorted(isort.settings.profiles)), + "py_version": st.sampled_from(("auto",) + isort.settings.VALID_PY_TARGETS), + } + kwargs = {**inferred_kwargs, **specific} + return st.fixed_dictionaries({}, optional=kwargs).map(_as_config) + + +st.register_type_strategy(isort.Config, configs()) + CODE_SNIPPET = """ '''Taken from bottle.py |