def testExtractEmailAddressesLoopRaisesError(self): """Checks that an error is raised if OWNERS file path results in a loop.""" file_directive_absolute_path = _MakeOwnersFile('loop_OWNERS', self.temp_dir) directive = _GetFileDirective(file_directive_absolute_path) with open(file_directive_absolute_path, 'w') as owners_file: owners_file.write(directive) with self.assertRaisesRegexp( expand_owners.Error, r'.*The path.*loop_OWNERS may be part of an OWNERS loop\.'): expand_owners._ExtractEmailAddressesFromOWNERS( file_directive_absolute_path)
def testExtractEmailAddressesUnsupportedSymbolsIgnored(self): """Checks that unsupported OWNERS files symbols are ignored. The unsupported symbols that may appear at the beginning of a line are as follows: (i) per-file (ii) * (iii) # (iv) set noparent (v) white space, e.g. a space or a blank line """ absolute_path = _MakeOwnersFile('OWNERS', self.temp_dir) joe = '*****@*****.**' unsupported_symbols = [ '# Words.', ' # Words.', '*', 'per-file *OWNERS=*', 'set noparent' ] with open(absolute_path, 'w') as owners_file: owners_file.write( '\n'.join([joe + ' # Words.', _DEFAULT_COMPONENT] + unsupported_symbols)) self.assertEqual( expand_owners._ExtractEmailAddressesFromOWNERS(absolute_path), [joe])