def TryListAttributeVariations(self, attribute_name, config_name,<EOL>default_expected):
<EOL>test_cases = ((None, ['<STR_LIT:foo>', '<STR_LIT:bar>'], ['<STR_LIT:foo>', '<STR_LIT:bar>']),<EOL>(None, [], None),<EOL>(['<STR_LIT:foo>', '<STR_LIT:bar>'], None, ['<STR_LIT:foo>', '<STR_LIT:bar>']),<EOL>(['<STR_LIT:foo>', '<STR_LIT:bar>'], ['<STR_LIT:foo>', '<STR_LIT:bar>'], ['<STR_LIT:foo>', '<STR_LIT:bar>']),<EOL>(['<STR_LIT:foo>', '<STR_LIT:bar>'], ['<STR_LIT:foo>', '<STR_LIT>'], ['<STR_LIT:foo>', '<STR_LIT>']),<EOL>(['<STR_LIT:foo>', '<STR_LIT:bar>'], [], None),<EOL>(['<STR_LIT:foo>', '<STR_LIT:bar>'], ['<STR_LIT:abc>'], ['<STR_LIT:abc>']),<EOL>(None, None, default_expected))<EOL>for api_value, method_value, expected_value in test_cases:<EOL><INDENT>api_kwargs = {attribute_name: api_value}<EOL>method_kwargs = {attribute_name: method_value}<EOL>@api_config.api('<STR_LIT>', '<STR_LIT>', hostname='<STR_LIT>',<EOL>**api_kwargs)<EOL>class AuthServiceImpl(remote.Service):<EOL><INDENT>"""<STR_LIT>"""<EOL>@api_config.method(**method_kwargs)<EOL>def baz(self):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>self.assertEqual(api_value if api_value is not None else default_expected,<EOL>getattr(AuthServiceImpl.api_info, attribute_name))<EOL>self.assertEqual(method_value,<EOL>getattr(AuthServiceImpl.baz.method_info, attribute_name))<EOL>generator = ApiConfigGenerator()<EOL>api = json.loads(generator.pretty_print_config_to_json(AuthServiceImpl))<EOL>expected = {<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': '<STR_LIT:POST>',<EOL>'<STR_LIT:path>': '<STR_LIT>',<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': {'<STR_LIT:body>': '<STR_LIT>'},<EOL>'<STR_LIT>': {'<STR_LIT:body>': '<STR_LIT>'},<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': ['<STR_LIT>'],<EOL>'<STR_LIT>': [API_EXPLORER_CLIENT_ID],<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>}<EOL>if expected_value:<EOL><INDENT>expected['<STR_LIT>'][config_name] = expected_value<EOL><DEDENT>elif config_name in expected['<STR_LIT>']:<EOL><INDENT>del expected['<STR_LIT>'][config_name]<EOL><DEDENT>test_util.AssertDictEqual(expected, api['<STR_LIT>'], self)<EOL><DEDENT>
Test setting an attribute in the API config and method configs.

        The audiences, scopes and allowed_client_ids settings can be set
        in either the main API config or on each of the methods.  This helper
        function tests each variation of one of these (whichever is specified)
        and ensures that the api config has the right values.

        Args:
          attribute_name: Name of the keyword arg to pass to the api or method
            decorator.  Also the name of the attribute used to access that
            variable on api_info or method_info.
          config_name: Name of the variable as it appears in the configuration
            output.
          default_expected: The default expected value if the attribute isn't
            specified on either the api or the method.