Example #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)
Example #2
0
 def test_parse(self):
     constraint = Constraint.parse("==1.0")
     self.assertEqual(constraint.operator, eq)
     self.assertEqual(constraint.version, Version(1))
Example #3
0
 def test_add(self):
     self.assertEqual(Constraint.parse(">1") + "<2", Constraints.parse(">1,<2"))
Example #4
0
 def test_repr(self):
     self.assertEqual(repr(Constraint.parse("==1")), "Constraint.parse('==1.0.0')")
Example #5
0
 def test_eq(self):
     self.assertEqual(Constraint.parse("==1.0"), Constraint.parse("==1.0"))
Example #6
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"))
Example #7
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')],
                         sorted([Constraint.parse('!=1.0.0'),
                                 Constraint.parse('!=2.0.0')]))
Example #8
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')])
Example #9
0
 def test_str(self):
     self.assertEqual(str(Constraints([Constraint.parse('>1'),
                                       Constraint.parse('<2')])),
                      '>1.0.0,<2.0.0')
Example #10
0
 def test_parse(self):
     constraint = Constraint.parse('==1.0')
     self.assertEqual(constraint.operator, eq)
     self.assertEqual(constraint.version, Version(1))
Example #11
0
 def test_add(self):
     self.assertEqual(
         Constraint.parse('>1') + '<2', Constraints.parse('>1,<2'))
Example #12
0
 def test_repr(self):
     self.assertEqual(repr(Constraint.parse('==1')),
                      "Constraint.parse('==1.0.0')")
Example #13
0
 def test_eq(self):
     self.assertEqual(Constraint.parse('==1.0'), Constraint.parse('==1.0'))
Example #14
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'))