Sitelet https://web.archive.org/web/20260624060415/https://github.com/RustPython/RustPython/pull/5444
Skip to content

Update fstring from v3.12.7#5444

Merged
youknowone merged 1 commit into
RustPython:mainfrom
key262yek:update_fstring_from_v3.12.7
Jan 10, 2025
Merged

Update fstring from v3.12.7#5444
youknowone merged 1 commit into
RustPython:mainfrom
key262yek:update_fstring_from_v3.12.7

Conversation

@key262yek

Copy link
Copy Markdown
Contributor

Update test_fstring.py from CPython v3.12.7

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing. Updating test_fstring seems a big task.

Please check the comment and other commented out test codes too to fit failing tests to our preference.

Comment thread Lib/test/test_fstring.py Outdated
self.assertEqual(t.body[1].value.values[0].lineno, 3)
self.assertEqual(t.body[1].value.values[1].lineno, 3)
self.assertEqual(t.body[1].value.values[2].lineno, 3)
# TODO: RUSTPYTHON self.assertEqual(t.body[1].value.values[1].lineno, 4)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually do not comment out test lines, but turn off the test itself.
Could you revert this part and mark test_ast_line_numbers_multiline_fstring as expectedFailure?

add expectedFailure to tag what should rustpython do
add comment for some syntaxerror which make test run broken
@key262yek key262yek force-pushed the update_fstring_from_v3.12.7 branch from 164bf6e to 40a9dda Compare December 5, 2024 06:08

@key262yek key262yek left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still struggle with rebase..
I made new branch with same name.
I remove comment from test, but some lines cannot be un-commented because of SyntaxError.

Comment thread Lib/test/test_fstring.py
Comment on lines +700 to +701
# TODO: RUSTPYTHON SyntaxError
# self.assertEqual(f'{' f'}', " f")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remove some comments, because it makes SyntaxError before test runs (so it cannot be passed by expectedFailure)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense. Thank you

Comment thread Lib/test/test_fstring.py
Comment on lines +761 to +769
# TODO: RUSTPYTHON SyntaxError
# self.assertEqual(
# f"""
# # this is not a comment
# { # the following operation it's
# 3 # this is a number
# * 2}""",
# "\n# this is not a comment\n6",
# )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one also

Comment thread Lib/test/test_fstring.py
Comment on lines +839 to +842
# TODO: RUSTPYTHON SyntaxError
# self.assertEqual(
# f"result: {value:{width:{0}}.{precision:1}}", "result: 12.35"
# )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

Comment thread Lib/test/test_fstring.py
Comment on lines +1089 to +1096
# TODO: RUSTPYTHON SyntaxError
# self.assertEqual(
# f"{(
# 1 +
# 2
# )}",
# "3",
# )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Comment thread Lib/test/test_fstring.py
Comment on lines +1266 to +1277
# TODO: RUSTPYTHON SyntaxError
# def test_expressions_with_triple_quoted_strings(self):
# self.assertEqual(f"{'''x'''}", 'x')
# self.assertEqual(f"{'''eric's'''}", "eric's")

# Test concatenation within an expression
# TODO: RUSTPYTHON self.assertEqual(f'{"x" """eric"s""" "y"}', 'xeric"sy')
# TODO: RUSTPYTHON self.assertEqual(f'{"x" """eric"s"""}', 'xeric"s')
# TODO: RUSTPYTHON self.assertEqual(f'{"""eric"s""" "y"}', 'eric"sy')
# TODO: RUSTPYTHON self.assertEqual(f'{"""x""" """eric"s""" "y"}', 'xeric"sy')
# TODO: RUSTPYTHON self.assertEqual(f'{"""x""" """eric"s""" """y"""}', 'xeric"sy')
# TODO: RUSTPYTHON self.assertEqual(f'{r"""x""" """eric"s""" """y"""}', 'xeric"sy')
# # Test concatenation within an expression
# self.assertEqual(f'{"x" """eric"s""" "y"}', 'xeric"sy')
# self.assertEqual(f'{"x" """eric"s"""}', 'xeric"s')
# self.assertEqual(f'{"""eric"s""" "y"}', 'eric"sy')
# self.assertEqual(f'{"""x""" """eric"s""" "y"}', 'xeric"sy')
# self.assertEqual(f'{"""x""" """eric"s""" """y"""}', 'xeric"sy')
# self.assertEqual(f'{r"""x""" """eric"s""" """y"""}', 'xeric"sy')

@key262yek key262yek Dec 5, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part is the reason why I commented line by line of broken assertion at first.
Only one assertion can be run, and others make SyntaxError

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets go with it. We can fix it once parser is changed

@youknowone youknowone merged commit 389b20d into RustPython:main Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants