mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testInvalidAttributes(self):
    """Tests that invalid attributes and attribute lists are correctly
    detected."""

    # Trailing commas not allowed.
    source1 = "[MyAttribute=MyName,] struct MyStruct {};"
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:1: Error: Unexpected '\]':\n"
        r"\[MyAttribute=MyName,\] struct MyStruct {};$"):
      parser.Parse(source1, "my_file.mojom")

    # Missing value.
    source2 = "[MyAttribute=] struct MyStruct {};"
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:1: Error: Unexpected '\]':\n"
        r"\[MyAttribute=\] struct MyStruct {};$"):
      parser.Parse(source2, "my_file.mojom")

    # Missing key.
    source3 = "[=MyName] struct MyStruct {};"
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:1: Error: Unexpected '=':\n"
        r"\[=MyName\] struct MyStruct {};$"):
      parser.Parse(source3, "my_file.mojom")
Tests that invalid attributes and attribute lists are correctly
    detected.
Tests that invalid attributes and attribute lists are correctly
detected.
Tests that invalid attributes and attribute lists are correctly detected .
def testInvalidAttributes(self):
    source1 = "[MyAttribute=MyName,] struct MyStruct {};"
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:1: Error: Unexpected '\]':\n"
        r"\[MyAttribute=MyName,\] struct MyStruct {};$"):
      parser.Parse(source1, "my_file.mojom")
    source2 = "[MyAttribute=] struct MyStruct {};"
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:1: Error: Unexpected '\]':\n"
        r"\[MyAttribute=\] struct MyStruct {};$"):
      parser.Parse(source2, "my_file.mojom")
    source3 = "[=MyName] struct MyStruct {};"
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:1: Error: Unexpected '=':\n"
        r"\[=MyName\] struct MyStruct {};$"):
      parser.Parse(source3, "my_file.mojom")
def testInvalidAttributes ( self ) : source1 = "[MyAttribute=MyName,] struct MyStruct {};" with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:1: Error: Unexpected '\]':\n" r"\[MyAttribute=MyName,\] struct MyStruct {};$" ) : parser . Parse ( source1 , "my_file.mojom" ) source2 = "[MyAttribute=] struct MyStruct {};" with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:1: Error: Unexpected '\]':\n" r"\[MyAttribute=\] struct MyStruct {};$" ) : parser . Parse ( source2 , "my_file.mojom" ) source3 = "[=MyName] struct MyStruct {};" with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:1: Error: Unexpected '=':\n" r"\[=MyName\] struct MyStruct {};$" ) : parser . Parse ( source3 , "my_file.mojom" )
Tests that invalid attributes and attribute lists are correctly
detected.
Tests that invalid attributes and attribute lists are correctly detected .
"""Tests that invalid attributes and attribute lists are correctly
    detected.""" # Trailing commas not allowed. # Missing value. # Missing key.
self