
from unittest import TestCase

from semver import compare
from semver import match
from semver import parse


class TestSemver(TestCase):
    def test_should_parse_version(self):
        self.assertEquals(
            parse("1.2.3-alpha.1.2+build.11.e0f985a"),
            {'major': 1,
             'minor': 2,
             'patch': 3,
             'prerelease': 'alpha.1.2',
             'build': 'build.11.e0f985a'})

    def test_should_get_less(self):
        self.assertEquals(
            compare("1.0.0", "2.0.0"),
            -1)

    def test_should_get_greater(self):
        self.assertEquals(
            compare("2.0.0", "1.0.0"),
            1)

    def test_should_match_simple(self):
        self.assertEquals(
            match("2.3.7", ">=2.3.6"),
            True)

    def test_should_no_match_simple(self):
        self.assertEquals(
            match("2.3.7", ">=2.3.8"),
            False)


from unittest import TestCase
from semver import compare
from semver import match
from semver import parse


class TestSemver(TestCase):
    def test_should_parse_version(self):
        self.assertEquals(
            parse("1.2.3-alpha.1.2+build.11.e0f985a"),
            {'major': 1,
             'minor': 2,
             'patch': 3,
             'prerelease': 'alpha.1.2',
             'build': 'build.11.e0f985a'})

    def test_should_get_less(self):
        self.assertEquals(
            compare("1.0.0", "2.0.0"),
            -1)

    def test_should_get_greater(self):
        self.assertEquals(
            compare("2.0.0", "1.0.0"),
            1)

    def test_should_match_simple(self):
        self.assertEquals(
            match("2.3.7", ">=2.3.6"),
            True)

    def test_should_no_match_simple(self):
        self.assertEquals(
            match("2.3.7", ">=2.3.8"),
            False)

    def test_should_raise_value_error_for_invalid_value(self):
        self.assertRaises(ValueError, compare, 'foo', 'bar')
        self.assertRaises(ValueError, compare, '1.0', '1.0.0')
        self.assertRaises(ValueError, compare, '1.x', '1.0.0')

    def test_should_raise_value_error_for_invalid_match_expression(self):
        self.assertRaises(ValueError, match, '1.0.0', '')
        self.assertRaises(ValueError, match, '1.0.0', '!')
        self.assertRaises(ValueError, match, '1.0.0', '1.0.0')

Add tests for error cases that proves incompatibility with Python 2.5 and early versions.
Add tests for error cases that proves incompatibility with Python 2.5 and early versions.

  
  from unittest import TestCase
- 
  from semver import compare
  from semver import match
  from semver import parse
  
  
  class TestSemver(TestCase):
      def test_should_parse_version(self):
          self.assertEquals(
              parse("1.2.3-alpha.1.2+build.11.e0f985a"),
              {'major': 1,
               'minor': 2,
               'patch': 3,
               'prerelease': 'alpha.1.2',
               'build': 'build.11.e0f985a'})
  
      def test_should_get_less(self):
          self.assertEquals(
              compare("1.0.0", "2.0.0"),
              -1)
  
      def test_should_get_greater(self):
          self.assertEquals(
              compare("2.0.0", "1.0.0"),
              1)
  
      def test_should_match_simple(self):
          self.assertEquals(
              match("2.3.7", ">=2.3.6"),
              True)
  
      def test_should_no_match_simple(self):
          self.assertEquals(
              match("2.3.7", ">=2.3.8"),
              False)
  
+     def test_should_raise_value_error_for_invalid_value(self):
+         self.assertRaises(ValueError, compare, 'foo', 'bar')
+         self.assertRaises(ValueError, compare, '1.0', '1.0.0')
+         self.assertRaises(ValueError, compare, '1.x', '1.0.0')
+ 
+     def test_should_raise_value_error_for_invalid_match_expression(self):
+         self.assertRaises(ValueError, match, '1.0.0', '')
+         self.assertRaises(ValueError, match, '1.0.0', '!')
+         self.assertRaises(ValueError, match, '1.0.0', '1.0.0')
+ 
Add tests for error cases that proves incompatibility with Python 2.5 and early versions.
## Code Before:

from unittest import TestCase

from semver import compare
from semver import match
from semver import parse


class TestSemver(TestCase):
    def test_should_parse_version(self):
        self.assertEquals(
            parse("1.2.3-alpha.1.2+build.11.e0f985a"),
            {'major': 1,
             'minor': 2,
             'patch': 3,
             'prerelease': 'alpha.1.2',
             'build': 'build.11.e0f985a'})

    def test_should_get_less(self):
        self.assertEquals(
            compare("1.0.0", "2.0.0"),
            -1)

    def test_should_get_greater(self):
        self.assertEquals(
            compare("2.0.0", "1.0.0"),
            1)

    def test_should_match_simple(self):
        self.assertEquals(
            match("2.3.7", ">=2.3.6"),
            True)

    def test_should_no_match_simple(self):
        self.assertEquals(
            match("2.3.7", ">=2.3.8"),
            False)

## Instruction:
Add tests for error cases that proves incompatibility with Python 2.5 and early versions.
## Code After:

from unittest import TestCase
from semver import compare
from semver import match
from semver import parse


class TestSemver(TestCase):
    def test_should_parse_version(self):
        self.assertEquals(
            parse("1.2.3-alpha.1.2+build.11.e0f985a"),
            {'major': 1,
             'minor': 2,
             'patch': 3,
             'prerelease': 'alpha.1.2',
             'build': 'build.11.e0f985a'})

    def test_should_get_less(self):
        self.assertEquals(
            compare("1.0.0", "2.0.0"),
            -1)

    def test_should_get_greater(self):
        self.assertEquals(
            compare("2.0.0", "1.0.0"),
            1)

    def test_should_match_simple(self):
        self.assertEquals(
            match("2.3.7", ">=2.3.6"),
            True)

    def test_should_no_match_simple(self):
        self.assertEquals(
            match("2.3.7", ">=2.3.8"),
            False)

    def test_should_raise_value_error_for_invalid_value(self):
        self.assertRaises(ValueError, compare, 'foo', 'bar')
        self.assertRaises(ValueError, compare, '1.0', '1.0.0')
        self.assertRaises(ValueError, compare, '1.x', '1.0.0')

    def test_should_raise_value_error_for_invalid_match_expression(self):
        self.assertRaises(ValueError, match, '1.0.0', '')
        self.assertRaises(ValueError, match, '1.0.0', '!')
        self.assertRaises(ValueError, match, '1.0.0', '1.0.0')
