Пример #1
0
    def test_merge(self):
        # should not merge requirements with other object types
        self.assertRaises(TypeError, Requirement('foo').__add__, None)
        # should not merge requirements for different packages
        self.assertRaises(InvalidRequirement, Requirement('foo').__add__,
                          Requirement('bar'))

        req = Requirement('foo>1.1,>1') + Requirement('foo<3,<2')
        self.assertTrue(req.satisfied_by({'name': 'foo', 'version': '1.5'}))
        self.assertFalse(req.satisfied_by({'name': 'foo', 'version': '1'}))
        self.assertFalse(req.satisfied_by({'name': 'foo', 'version': '2'}))
Пример #2
0
 def test_complex_1(self):
     req = Requirement('foo>1,>2')
     self.assertFalse(req.satisfied_by({'name': 'foo', 'version': '1.5'}))
     self.assertFalse(req.satisfied_by({'name': 'foo', 'version': '2'}))
     self.assertTrue(req.satisfied_by({'name': 'foo', 'version': '2.1'}))
     req = Requirement('foo>2,>1')
     self.assertFalse(req.satisfied_by({'name': 'foo', 'version': '1.5'}))
     self.assertFalse(req.satisfied_by({'name': 'foo', 'version': '2'}))
     self.assertTrue(req.satisfied_by({'name': 'foo', 'version': '2.1'}))
Пример #3
0
 def test_complex_3(self):
     req = Requirement('foo<3,<=3')
     self.assertFalse(req.satisfied_by({'name': 'foo', 'version': '3'}))
     self.assertTrue(req.satisfied_by({'name': 'foo', 'version': '1'}))
     req = Requirement('foo<=3,<3')
     self.assertFalse(req.satisfied_by({'name': 'foo', 'version': '3'}))
     self.assertTrue(req.satisfied_by({'name': 'foo', 'version': '1'}))
Пример #4
0
 def test_satisfied_by(self):
     req = Requirement('foo >= 1.0, < 2')
     self.assertTrue(req.satisfied_by(Package('foo', '1.0')))
     self.assertFalse(req.satisfied_by(Package('foo', '2.0')))
     self.assertFalse(req.satisfied_by(Package('foo', '0.42')))