def test_root(self): self.assertEqual( self.c.install_sequence(Req('numpy 1.5.1'), mode='root'), [self.repos['epd'] + 'numpy-1.5.1-2.egg']) self.assertEqual( self.c.install_sequence(Req('numpy 1.5.1-1'), mode='root'), [self.repos['epd'] + 'numpy-1.5.1-1.egg'])
def test_misc_methods(self): for req_string in ['', 'foo', 'bar 1.2', 'baz 2.6.7-5']: r = Req(req_string) self.assertEqual(str(r), req_string) self.assertEqual(r, r) self.assertEqual(eval(repr(r)), r) self.assertNotEqual(Req('foo'), Req('bar')) self.assertNotEqual(Req('foo 1.4'), Req('foo 1.4-5'))
def test_reqs_dist(self): dist = self.repos['epd'] + 'FiPy-2.1-1.egg' self.assertEqual( self.c.reqs_dist(dist), set([ Req('distribute'), Req('scipy'), Req('numpy'), Req('pysparse 1.2.dev203') ]))
def test_get_repo(self): for req_string, repo_name in [ ('MySQL_python', 'gpl'), ('bitarray', 'epd'), ('foobar', None), ]: self.assertEqual(self.c.get_repo(Req(req_string)), self.repos[repo_name])
def test_dist_as_req(self): for req_string, s in [ ('numpy', 1), ('numpy 1.3.0', 2), ('numpy 1.3.0-2', 3), ]: req = dist_as_req('file:///numpy-1.3.0-2.egg', s) self.assertEqual(req, Req(req_string)) self.assertEqual(req.strictness, s)
def test_add_Reqs_to_spec(self): spec = dict(name='dummy', packages=[]) add_Reqs_to_spec(spec) self.assertEqual(spec['Reqs'], set()) spec = dict(name='dumy', packages=['numpy 1.3.0']) add_Reqs_to_spec(spec) Reqs = spec['Reqs'] self.assertEqual(len(Reqs), 1) self.assertEqual(Reqs, set([Req('numpy 1.3.0')]))
def test_get_dist(self): for req_string, dist in [ ('MySQL_python', self.repos['gpl'] + 'MySQL_python-1.2.3-2.egg'), ('numpy', self.repos['epd'] + 'numpy-1.6.0-3.egg'), ('swig', self.repos['epd'] + 'swig-1.3.40-2.egg'), ('swig 1.3.36', self.repos['epd'] + 'swig-1.3.36-3.egg'), ('swig 1.3.40-1', self.repos['epd'] + 'swig-1.3.40-1.egg'), ('swig 1.3.40-2', self.repos['epd'] + 'swig-1.3.40-2.egg'), ('foobar', None), ]: self.assertEqual(self.c.get_dist(Req(req_string)), dist)
def test_init(self): for req_string, name, version, build, strictness in [ ('', None, None, None, 0), (' \t', None, None, None, 0), ('foo', 'foo', None, None, 1), ('bar 1.9', 'bar', '1.9', None, 2), ('baz 1.8-2', 'baz', '1.8', 2, 3), ]: r = Req(req_string) self.assertEqual(r.name, name) self.assertEqual(r.version, version) self.assertEqual(r.build, build) self.assertEqual(r.strictness, strictness)
def test_matches_py(self): spec = dict(metadata_version='1.1', cname='foo', version='2.4.1', build=3, python=None) for py in ['2.4', '2.5', '2.6', '3.1']: requirement.PY_VER = py self.assertEqual(Req('foo').matches(spec), True) spec25 = dict(spec) spec25.update(dict(python='2.5')) spec26 = dict(spec) spec26.update(dict(python='2.6')) requirement.PY_VER = '2.5' self.assertEqual(Req('foo').matches(spec25), True) self.assertEqual(Req('foo').matches(spec26), False) requirement.PY_VER = '2.6' self.assertEqual(Req('foo').matches(spec25), False) self.assertEqual(Req('foo').matches(spec26), True)
def test_matches(self): spec = dict(metadata_version='1.1', cname='foo_bar', version='2.4.1', build=3, python=None) for req_string, m in [ ('', True), ('foo', False), ('Foo-BAR', True), ('foo-Bar 2.4.1', True), ('FOO-Bar 1.8.7', False), ('FOO-BAR 2.4.1-3', True), ('FOO-Bar 2.4.1-1', False), ]: self.assertEqual(Req(req_string).matches(spec), m, req_string)
def test_multiple_reqs(self): lst = self.c.install_sequence(Req('ets')) self.assert_(self.repos['epd'] + 'numpy-1.5.1-2.egg' in lst)
def test_flat_recur2(self): for rs in 'epd 7.0', 'epd 7.0-1', 'epd 7.0-2': d1 = self.c.install_sequence(Req(rs), mode='flat') d2 = self.c.install_sequence(Req(rs), mode='recur') self.assertEqual(d1, d2)
def test_flat_recur1(self): d1 = self.c.install_sequence(Req('openepd'), mode='flat') d2 = self.c.install_sequence(Req('openepd'), mode='recur') self.assertEqual(d1, d2) d3 = self.c.install_sequence(Req('foo'), mode='recur') self.assertEqual(d2[:-1], d3[:-1])
def test_order2(self): self.assertEqual(self.c.install_sequence(Req('scipy')), [ self.repos['epd'] + egg for egg in 'MKL-10.3-1.egg', 'numpy-1.5.1-2.egg', 'scipy-0.9.0-1.egg' ])
def test_order1(self): self.assertEqual(self.c.install_sequence(Req('numpy')), [ self.repos['epd'] + egg for egg in 'MKL-10.3-1.egg', 'numpy-1.6.0-3.egg' ])
def eggs_rs(c, req_string): return [ dist_naming.filename_dist(d) for d in c.install_sequence(Req(req_string)) ]