MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_comments

Method test_comments

Lib/test/test_fstring.py:743–792  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

741
742 @unittest.expectedFailure # TODO: RUSTPYTHON
743 def test_comments(self):
744 # These aren't comments, since they're in strings.
745 d = {'#': 'hash'}
746 self.assertEqual(f'{"#"}', '#')
747 self.assertEqual(f'{d["#"]}', 'hash')
748
749 self.assertAllRaise(SyntaxError, "'{' was never closed",
750 ["f'{1#}'", # error because everything after '#' is a comment
751 "f'{#}'",
752 "f'one: {1#}'",
753 "f'{1# one} {2 this is a comment still#}'",
754 ])
755 self.assertAllRaise(SyntaxError, r"f-string: unmatched '\)'",
756 ["f'{)#}'", # When wrapped in parens, this becomes
757 # '()#)'. Make sure that doesn't compile.
758 ])
759 self.assertEqual(f'''A complex trick: {
7602 # two
761}''', 'A complex trick: 2')
762 self.assertEqual(f'''
763{
76440 # forty
765+ # plus
7662 # two
767}''', '\n42')
768 self.assertEqual(f'''
769{
77040 # forty
771+ # plus
7722 # two
773}''', '\n42')
774
775 self.assertEqual(f'''
776# this is not a comment
777{ # the following operation it's
7783 # this is a number
779* 2}''', '\n# this is not a comment\n6')
780 self.assertEqual(f'''
781{# f'a {comment}'
78286 # constant
783# nothing more
784}''', '\n86')
785
786 self.assertAllRaise(SyntaxError, r"f-string: valid expression required before '}'",
787 ["""f'''
788{
789# only a comment
790}'''
791""", # this is equivalent to f'{}'
792 ])
793
794 def test_many_expressions(self):
795 # Create a string with many expressions in it. Note that

Callers

nothing calls this directly

Calls 2

assertEqualMethod · 0.95
assertAllRaiseMethod · 0.95

Tested by

no test coverage detected