예제 #1
0
 def test_add(self):
     self.assertEqual(Constraints() + '>1', Constraints.parse('>1'))
     self.assertEqual(Constraints() + Constraints.parse('>1'),
                      Constraints.parse('>1'))
     self.assertEqual(Constraints() + Constraint.parse('>1'),
                      Constraints.parse('>1'))
     self.assertRaises(TypeError, Constraints().__add__, 42)
예제 #2
0
    def test(self):

        constraints = [Constraint.parse('>1'), Constraint.parse('<2')]
        self.assertMerge(constraints, constraints)

        self.assertMerge([Constraint.parse('<2'), Constraint.parse('<3')],
                         [Constraint.parse('<2.0.0')])

        self.assertMerge([Constraint.parse('<2'), Constraint.parse('>=1')],
                         [Constraint.parse('>=1.0.0'), Constraint.parse('<2.0.0')])

        self.assertMerge([Constraint.parse('>=2'), Constraint.parse('>2')],
                         [Constraint.parse('>2.0.0')])

        self.assertMerge([Constraint.parse('>1'), Constraint.parse('>=2')],
                         [Constraint.parse('>=2.0.0')])

        self.assertMerge([Constraint.parse('<2'), Constraint.parse('<=1')],
                         [Constraint.parse('<=1.0.0')])

        self.assertMerge([Constraint.parse('<=2'), Constraint.parse('<1')],
                         [Constraint.parse('<1.0.0')])

        self.assertMerge([Constraint.parse('<=2'), Constraint.parse('>=2')],
                         [Constraint.parse('==2.0.0')])

        # Negative constraints should not be omitted!
        self.assertMerge([Constraint.parse('!=2'), Constraint.parse('!=1')],
                         [Constraint.parse('!=1.0.0'), Constraint.parse('!=2.0.0')])
예제 #3
0
 def test_raises_ExclusiveConstraints(self):
     self.assertRaises(ExclusiveConstraints, merge,
                       [Constraint.parse('==1'), Constraint.parse('==2')])
     self.assertRaises(ExclusiveConstraints, merge,
                       [Constraint.parse('>2'), Constraint.parse('<1')])
     self.assertRaises(ExclusiveConstraints, merge,
                       [Constraint.parse('>2'), Constraint.parse('<2')])
     self.assertRaises(ExclusiveConstraints, merge,
                       [Constraint.parse('>2'), Constraint.parse('<=2')])
     # the first 2 constraints will be merge into ==2,
     # which conflicts with !=2
     self.assertRaises(ExclusiveConstraints, merge,
                       [Constraint.parse('<=2'), Constraint.parse('>=2'),
                        Constraint.parse('!=2')])
예제 #4
0
 def test_str(self):
     self.assertEqual(str(Constraints([Constraint.parse('>1'),
                                       Constraint.parse('<2')])),
                      '>1.0.0,<2.0.0')
예제 #5
0
 def test_add(self):
     self.assertEqual(Constraint.parse('>1') + '<2',
                      Constraints.parse('>1,<2'))
예제 #6
0
 def test_repr(self):
     self.assertEqual(repr(Constraint.parse('==1')),
                      "Constraint.parse('==1.0.0')")
예제 #7
0
 def test_eq(self):
     self.assertEqual(Constraint.parse('==1.0'), Constraint.parse('==1.0'))
예제 #8
0
 def test_match(self):
     self.assertTrue(Constraint.parse('==1.0').match(Version(1)))
     self.assertTrue('1' in Constraint.parse('==1.0'))
     self.assertTrue('2' in Constraint.parse('>1.0'))
예제 #9
0
 def test_parse(self):
     constraint = Constraint.parse('==1.0')
     self.assertEqual(constraint.operator, eq)
     self.assertEqual(constraint.version, Version(1))