Пример #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))