Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and extra tests for literals #115

Merged
merged 13 commits into from
Jan 28, 2025
71 changes: 71 additions & 0 deletions rewrite/tests/python/all/format/tabs_and_indents_visitor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,77 @@ def my_function(a, b):
return None


def test_string_literal_assignment():
style = IntelliJ.tabs_and_indents().with_use_tab_character(False).with_tab_size(4)
rewrite_run(
# language=python
python(
'''
a = """
This is a string that
should not be modified.
"""
'''
),
spec=RecipeSpec().with_recipes(from_visitor(TabsAndIndentsVisitor(style)))
)


def test_string_literal_assignment_in_function():
style = IntelliJ.tabs_and_indents().with_use_tab_character(False).with_tab_size(4)
rewrite_run(
# language=python
python(
'''
def my_function():
a = """
This is a string that
should align with the function body.
"""
return None
knutwannheden marked this conversation as resolved.
Show resolved Hide resolved
''',
'''
def my_function():
a = """
This is a string that
should align with the function body.
"""
return None
'''
),
spec=RecipeSpec().with_recipes(from_visitor(TabsAndIndentsVisitor(style)))
)


def test_string_literal_comment():
style = IntelliJ.tabs_and_indents().with_use_tab_character(False).with_tab_size(4)
rewrite_run(
# language=python
python(
'''
"""
This is a comment that
should not be modified.
"""
'''
),
spec=RecipeSpec().with_recipes(from_visitor(TabsAndIndentsVisitor(style)))
)


def test_int_literal_comment():
style = IntelliJ.tabs_and_indents().with_use_tab_character(False).with_tab_size(4)
rewrite_run(
# language=python
python(
'''
1
'''
),
spec=RecipeSpec().with_recipes(from_visitor(TabsAndIndentsVisitor(style)))
)


def test_docstring_alignment():
style = IntelliJ.tabs_and_indents().with_use_tab_character(False).with_tab_size(4)
rewrite_run(
Expand Down
Loading