Debian Codegraph @

tests/unit/test_comments.py

raw
1 from hypothesis import given
2 from hypothesis import strategies as st
3
4 import isort.comments
5
6
7 def test_add_to_line() -> None:
8 assert (
9 isort.comments.add_to_line([], "import os # comment", removed=True).strip() == "import os"
10 )
11
12
13 # These tests were written by the `hypothesis.extra.ghostwriter` module
14 # and is provided under the Creative Commons Zero public domain dedication.
15
16
17 @given(
18 comments=st.one_of(st.none(), st.lists(st.text())),
19 original_string=st.text(),
20 removed=st.booleans(),
21 comment_prefix=st.text(),
22 )
23 def test_fuzz_add_to_line(
24 comments: list[str] | None, original_string: str, removed: bool, comment_prefix: str
25 ) -> None:
26 isort.comments.add_to_line(
27 comments=comments,
28 original_string=original_string,
29 removed=removed,
30 comment_prefix=comment_prefix,
31 )
32
33
34 @given(line=st.text())
35 def test_fuzz_parse(line: str) -> None:
36 isort.comments.parse(line=line)