def _assert_versiontool_result(self, control, expected):
        """Asserts that VersionTool's result equals the expected dictionary.

    Args:
      control: The control struct to pass to VersionTool. See the module doc for
          the versiontool module for a description of this format.
      expected: The dictionary that represents the expected result from running
          VersionTool.
    """
        outdict = versiontool.VersionTool(control).run()
        self.assertEqual(expected, outdict)
 def test_raises_if_label_is_present_but_does_not_match(self):
   with self.assertRaises(versiontool.VersionToolError) as context:
     versiontool.VersionTool({
         'build_info_path': io.StringIO('BUILD_EMBED_LABEL app_3.1_RC41',),
         'build_label_pattern': 'app_{version}_RC{candidate}',
         'build_version_pattern': '{version}.{candidate}',
         'capture_groups': {
             'version': r'\d+\.\d+\.\d+',
             'candidate': r'\d+',
         },
         'short_version_string_pattern': '{version}',
     }).run()
 def test_raises_if_fallback_label_is_present_but_does_not_match(self):
     with self.assertRaises(versiontool.VersionToolError) as context:
         versiontool.VersionTool({
             'build_info_path':
             _str_io('FOO 123'),
             'fallback_build_label':
             'app_3.1_RC41',
             'build_label_pattern':
             'app_{version}_RC{candidate}',
             'build_version_pattern':
             '{version}.{candidate}',
             'capture_groups': {
                 'version': r'\d+\.\d+\.\d+',
                 'candidate': r'\d+',
             },
             'short_version_string_pattern':
             '{version}',
         }).run()