Exemple #1
0
 def test_eq_both_unparsable(self):
     """Assert unparsable versions that are the same string are equal."""
     v1 = base.Version(version="arg")
     v2 = base.Version(version="arg")
     v1.parse = mock.Mock(side_effect=exceptions.InvalidVersion("arg"))
     v2.parse = mock.Mock(side_effect=exceptions.InvalidVersion("arg"))
     self.assertEqual(v1, v2)
Exemple #2
0
 def test_lt_both_unparsable(self):
     """Assert unparsable versions resort to string sorting."""
     alphabetically_lower = base.Version(version="arg")
     alphabetically_lower.parse = mock.Mock(
         side_effect=exceptions.InvalidVersion("arg"))
     alphabetically_higher = base.Version(version="blarg")
     alphabetically_higher.parse = mock.Mock(
         side_effect=exceptions.InvalidVersion("blarg"))
     self.assertTrue(alphabetically_lower < alphabetically_higher)
Exemple #3
0
 def test_lt_one_unparsable(self):
     """Assert unparsable versions sort lower than parsable ones."""
     unparsable_version = base.Version(version="blarg")
     unparsable_version.parse = mock.Mock(
         side_effect=exceptions.InvalidVersion("blarg"))
     new_version = base.Version(version="v1.0.0")
     self.assertTrue(unparsable_version < new_version)
     self.assertFalse(new_version < unparsable_version)
Exemple #4
0
 def test_str_with_wrapped_exception(self):
     """Assert the __str__ method provides a human-readable value including the exception."""
     e = exceptions.InvalidVersion('notaversion', IOError('womp womp'))
     self.assertEqual('Invalid version "notaversion": womp womp', str(e))
Exemple #5
0
 def test_str(self):
     """Assert the __str__ method provides a human-readable value."""
     e = exceptions.InvalidVersion('notaversion')
     self.assertEqual('Invalid version "notaversion"', str(e))
Exemple #6
0
 def test_str_parse_error(self):
     """Assert __str__ calls parse"""
     version = base.Version(version="v1.0.0")
     version.parse = mock.Mock(
         side_effect=exceptions.InvalidVersion("boop"))
     self.assertEqual("v1.0.0", str(version))
 def test_str_parse_error(self):
     """Assert __str__ calls parse"""
     version = rpm.RpmVersion(version='v1.0.0')
     version.parse = mock.Mock(
         side_effect=exceptions.InvalidVersion('boop'))
     self.assertEqual('v1.0.0', str(version))