tools/metrics/histograms/expand_owners_unittest.py
def testExpandOwnersWithoutOwnersFromFile(self):
    """Checks that an error is raised when no owners can be derived."""
    absolute_path = _MakeOwnersFile('empty_OWNERS', self.temp_dir)
    src_relative_path = _GetSrcRelativePath(absolute_path)

    with open(absolute_path, 'w') as owners_file:
      owners_file.write('')  # Write to the file so that it exists.

    histograms_without_owners_from_file = xml.dom.minidom.parseString("""
<histograms>

<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>{}</owner>
  <summary>I like coffee.</summary>
</histogram>

</histograms>
""".format(src_relative_path))

    with self.assertRaisesRegexp(
        expand_owners.Error,
        r'No emails could be derived from .*empty_OWNERS\.'):
      expand_owners.ExpandHistogramsOWNERS(histograms_without_owners_from_file)
Checks that an error is raised when no owners can be derived.
Checks that an error is raised when no owners can be derived.
Checks that an error is raised when no owners can be derived .
def testExpandOwnersWithoutOwnersFromFile(self):
    absolute_path = _MakeOwnersFile('empty_OWNERS', self.temp_dir)
    src_relative_path = _GetSrcRelativePath(absolute_path)
    with open(absolute_path, 'w') as owners_file:
      owners_file.write('')  
    histograms_without_owners_from_file = xml.dom.minidom.parseString("""
<histograms>
<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>{}</owner>
  <summary>I like coffee.</summary>
</histogram>
</histograms>
""".format(src_relative_path))
    with self.assertRaisesRegexp(
        expand_owners.Error,
        r'No emails could be derived from .*empty_OWNERS\.'):
      expand_owners.ExpandHistogramsOWNERS(histograms_without_owners_from_file)
def testExpandOwnersWithoutOwnersFromFile ( self ) : absolute_path = _MakeOwnersFile ( 'empty_OWNERS' , self . temp_dir ) src_relative_path = _GetSrcRelativePath ( absolute_path ) with open ( absolute_path , 'w' ) as owners_file : owners_file . write ( '' ) histograms_without_owners_from_file = xml . dom . minidom . parseString ( """
<histograms>

<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>{}</owner>
  <summary>I like coffee.</summary>
</histogram>

</histograms>
""" . format ( src_relative_path ) ) with self . assertRaisesRegexp ( expand_owners . Error , r'No emails could be derived from .*empty_OWNERS\.' ) : expand_owners . ExpandHistogramsOWNERS ( histograms_without_owners_from_file )
Checks that an error is raised when no owners can be derived.
Checks that an error is raised when no owners can be derived .
"""Checks that an error is raised when no owners can be derived.""" # Write to the file so that it exists.
self