# Path: poet/version_parser.py
# class VersionParser(object):
# 
#     _constraints = {}
# 
#     def parse_constraints(self, constraints):
#         if not isinstance(constraints, list):
#             constraints = constraints.replace(', ', ',')
#         else:
#             constraints = ','.join(constraints)
# 
#         if constraints not in self.__class__._constraints:
#             specs = Spec(constraints)
# 
#             self.__class__._constraints[constraints] = specs
# 
#         return self.__class__._constraints[constraints]
# 
#     @classmethod
#     def parse_stability(cls, version):
#         if not isinstance(version, Version):
#             version = Version.coerce(version)
# 
#         if version.prerelease:
#             return 'dev'
# 
#         return 'stable'
# 
#     def parse_name_version_pairs(self, pairs):
#         result = []
# 
#         for pair in pairs:
#             pair = re.sub('^([^=: ]+)[=: ](.*)$', '\\1 \\2', pair.strip())
# 
#             if ' ' in pair:
#                 name, version = pair.split(' ', 2)
# 
#                 result.append({
#                     'name': name,
#                     'version': version
#                 })
#             else:
#                 result.append({
#                     'name': pair,
#                     'version': '*'
#                 })
# 
#         return result


from semantic_version import Spec
from poet.version_parser import VersionParser
# -*- coding: utf-8 -*-



def test_parse_constraints():
    parser = VersionParser()

    assert Spec('>=1.2.3,<2') == parser.parse_constraints('>=1.2.3,<2')
    assert Spec('>=1.2.3,<2') == parser.parse_constraints('>=1.2.3, <2')
    assert Spec('>=1.2.3,<2') == parser.parse_constraints(['>=1.2.3','<2'])

def test_parse_stability():
    assert 'stable' == VersionParser.parse_stability('1.2.3')

# Path: poet/version_parser.py
# class VersionParser(object):
# 
#     _constraints = {}
# 
#     def parse_constraints(self, constraints):
#         if not isinstance(constraints, list):
#             constraints = constraints.replace(', ', ',')
#         else:
#             constraints = ','.join(constraints)
# 
#         if constraints not in self.__class__._constraints:
#             specs = Spec(constraints)
# 
#             self.__class__._constraints[constraints] = specs
# 
#         return self.__class__._constraints[constraints]
# 
#     @classmethod
#     def parse_stability(cls, version):
#         if not isinstance(version, Version):
#             version = Version.coerce(version)
# 
#         if version.prerelease:
#             return 'dev'
# 
#         return 'stable'
# 
#     def parse_name_version_pairs(self, pairs):
#         result = []
# 
#         for pair in pairs:
#             pair = re.sub('^([^=: ]+)[=: ](.*)$', '\\1 \\2', pair.strip())
# 
#             if ' ' in pair:
#                 name, version = pair.split(' ', 2)
# 
#                 result.append({
#                     'name': name,
#                     'version': version
#                 })
#             else:
#                 result.append({
#                     'name': pair,
#                     'version': '*'
#                 })
# 
#         return result


# Path: tests/test_version_parser.py
from semantic_version import Spec
from poet.version_parser import VersionParser

# -*- coding: utf-8 -*-



def test_parse_constraints():
    parser = VersionParser()

    assert Spec('>=1.2.3,<2') == parser.parse_constraints('>=1.2.3,<2')
    assert Spec('>=1.2.3,<2') == parser.parse_constraints('>=1.2.3, <2')
    assert Spec('>=1.2.3,<2') == parser.parse_constraints(['>=1.2.3','<2'])

def test_parse_stability():
    assert 'stable' == VersionParser.parse_stability('1.2.3')

    assert 'dev' == VersionParser.parse_stability('1.2.3b1')