def test_circular_dependencies(): index2 = index.copy() index2['package1-1.0-0.tar.bz2'] = IndexRecord(**{ 'build': '0', 'build_number': 0, 'depends': ['package2'], 'name': 'package1', 'requires': ['package2'], 'version': '1.0', }) index2['package2-1.0-0.tar.bz2'] = IndexRecord(**{ 'build': '0', 'build_number': 0, 'depends': ['package1'], 'name': 'package2', 'requires': ['package1'], 'version': '1.0', }) index2 = {Dist(key): value for key, value in iteritems(index2)} r = Resolve(index2) assert set(r.find_matches(MatchSpec('package1'))) == { Dist('package1-1.0-0.tar.bz2'), } assert set(r.get_reduced_index(['package1']).keys()) == { Dist('package1-1.0-0.tar.bz2'), Dist('package2-1.0-0.tar.bz2'), } assert r.install(['package1']) == r.install(['package2']) == \ r.install(['package1', 'package2']) == [ Dist('package1-1.0-0.tar.bz2'), Dist('package2-1.0-0.tar.bz2'), ]
def test_install_package_with_feature(): index2 = index.copy() index2['mypackage-1.0-featurepy33_0.tar.bz2'] = IndexRecord( **{ "channel": "defaults", "subdir": context.subdir, "md5": "0123456789", "fn": "doesnt-matter-here", 'build': 'featurepy33_0', 'build_number': 0, 'depends': ['python 3.3*'], 'name': 'mypackage', 'version': '1.0', 'features': 'feature', }) index2['feature-1.0-py33_0.tar.bz2'] = IndexRecord( **{ "channel": "defaults", "subdir": context.subdir, "md5": "0123456789", "fn": "doesnt-matter-here", 'build': 'py33_0', 'build_number': 0, 'depends': ['python 3.3*'], 'name': 'feature', 'version': '1.0', 'track_features': 'feature', }) index2 = {Dist(key): value for key, value in iteritems(index2)} r = Resolve(index2) # It should not raise r.install(['mypackage', 'feature 1.0'])
def test_install_package_with_feature(): index2 = index.copy() index2['mypackage-1.0-featurepy33_0.tar.bz2'] = IndexRecord( **{ 'build': 'featurepy33_0', 'build_number': 0, 'depends': ['python 3.3*'], 'name': 'mypackage', 'version': '1.0', 'features': 'feature', }) index2['feature-1.0-py33_0.tar.bz2'] = IndexRecord( **{ 'build': 'py33_0', 'build_number': 0, 'depends': ['python 3.3*'], 'name': 'feature', 'version': '1.0', 'track_features': 'feature', }) index2 = {Dist(key): value for key, value in iteritems(index2)} r = Resolve(index2) # It should not raise r.install(['mypackage', 'feature 1.0'])
def test_install_tarball_from_local_channel(self): with make_temp_env("flask=0.10.1") as prefix: assert_package_is_installed(prefix, 'flask-0.10.1') flask_data = [ p for p in itervalues(linked_data(prefix)) if p['name'] == 'flask' ][0] run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0.10.1') assert_package_is_installed(prefix, 'python') flask_fname = flask_data['fn'] tar_old_path = join(context.pkgs_dirs[0], flask_fname) # Regression test for #2812 # install from local channel flask_data = flask_data.dump() for field in ('url', 'channel', 'schannel'): del flask_data[field] repodata = { 'info': {}, 'packages': { flask_fname: IndexRecord(**flask_data) } } with make_temp_env() as channel: subchan = join(channel, context.subdir) noarch_dir = join(channel, 'noarch') channel = path_to_url(channel) os.makedirs(subchan) os.makedirs(noarch_dir) tar_new_path = join(subchan, flask_fname) copyfile(tar_old_path, tar_new_path) with bz2.BZ2File(join(subchan, 'repodata.json.bz2'), 'w') as f: f.write( json.dumps(repodata, cls=EntityEncoder).encode('utf-8')) with bz2.BZ2File(join(noarch_dir, 'repodata.json.bz2'), 'w') as f: f.write(json.dumps({}, cls=EntityEncoder).encode('utf-8')) run_command(Commands.INSTALL, prefix, '-c', channel, 'flask', '--json') assert_package_is_installed(prefix, channel + '::' + 'flask-') run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0') # Regression test for 2970 # install from build channel as a tarball conda_bld = join(sys.prefix, 'conda-bld') conda_bld_sub = join(conda_bld, context.subdir) if not isdir(conda_bld_sub): os.makedirs(conda_bld_sub) tar_bld_path = join(conda_bld_sub, flask_fname) copyfile(tar_new_path, tar_bld_path) # CondaFileNotFoundError: '/home/travis/virtualenv/python2.7.9/conda-bld/linux-64/flask-0.10.1-py27_2.tar.bz2'. run_command(Commands.INSTALL, prefix, tar_bld_path) assert_package_is_installed(prefix, 'flask-')
def test_optional_dependencies(): index2 = index.copy() index2['package1-1.0-0.tar.bz2'] = IndexRecord(**{ 'build': '0', 'build_number': 0, 'depends': ['package2 >1.0 (optional)'], 'name': 'package1', 'requires': ['package2'], 'version': '1.0', }) index2['package2-1.0-0.tar.bz2'] = IndexRecord(**{ 'build': '0', 'build_number': 0, 'depends': [], 'name': 'package2', 'requires': [], 'version': '1.0', }) index2['package2-2.0-0.tar.bz2'] = IndexRecord(**{ 'build': '0', 'build_number': 0, 'depends': [], 'name': 'package2', 'requires': [], 'version': '2.0', }) index2 = {Dist(key): value for key, value in iteritems(index2)} r = Resolve(index2) assert set(r.find_matches(MatchSpec('package1'))) == { Dist('package1-1.0-0.tar.bz2'), } assert set(r.get_reduced_index(['package1']).keys()) == { Dist('package1-1.0-0.tar.bz2'), Dist('package2-2.0-0.tar.bz2'), } assert r.install(['package1']) == [ Dist('package1-1.0-0.tar.bz2'), ] assert r.install(['package1', 'package2']) == r.install(['package1', 'package2 >1.0']) == [ Dist('package1-1.0-0.tar.bz2'), Dist('package2-2.0-0.tar.bz2'), ] assert raises(UnsatisfiableError, lambda: r.install(['package1', 'package2 <2.0'])) assert raises(UnsatisfiableError, lambda: r.install(['package1', 'package2 1.0']))
def test_circular_dependencies(): index2 = index.copy() index2['package1-1.0-0.tar.bz2'] = IndexRecord( **{ "channel": "defaults", "subdir": context.subdir, "md5": "0123456789", "fn": "doesnt-matter-here", 'build': '0', 'build_number': 0, 'depends': ['package2'], 'name': 'package1', 'requires': ['package2'], 'version': '1.0', }) index2['package2-1.0-0.tar.bz2'] = IndexRecord( **{ "channel": "defaults", "subdir": context.subdir, "md5": "0123456789", "fn": "doesnt-matter-here", 'build': '0', 'build_number': 0, 'depends': ['package1'], 'name': 'package2', 'requires': ['package1'], 'version': '1.0', }) index2 = {Dist(key): value for key, value in iteritems(index2)} r = Resolve(index2) assert set(r.find_matches(MatchSpec('package1'))) == { Dist('package1-1.0-0.tar.bz2'), } assert set(r.get_reduced_index(['package1']).keys()) == { Dist('package1-1.0-0.tar.bz2'), Dist('package2-1.0-0.tar.bz2'), } assert r.install(['package1']) == r.install(['package2']) == \ r.install(['package1', 'package2']) == [ Dist('package1-1.0-0.tar.bz2'), Dist('package2-1.0-0.tar.bz2'), ]
def DPkg(s, **kwargs): d = Dist(s) return IndexRecord( fn=d.to_filename(), name=d.name, version=d.version, build=d.build_string, build_number=int(d.build_string.rsplit('_', 1)[-1]), schannel=d.channel, **kwargs)
def DPkg(s, **kwargs): d = Dist(s) return IndexRecord(fn=d.to_filename(), name=d.name, version=d.version, build=d.build_string, build_number=int(d.build_string.rsplit('_', 1)[-1]), channel=d.channel, subdir=context.subdir, md5="012345789", **kwargs)
def test_package_info(self): index_json_record = IndexRecord(build=0, build_number=0, name="test_foo", version=0, channel='defaults', subdir=context.subdir, fn='doesnt-matter', md5='0123456789') icondata = "icondata" package_metadata = PackageMetadata( package_metadata_version=1, noarch=Noarch(type="python", entry_points=["test:foo"]), ) paths = [ PathData( _path="test/path/1", file_mode=FileMode.text, path_type=PathType.hardlink, prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), PathData(_path="test/path/2", no_link=True, path_type=PathType.hardlink), PathData(_path="test/path/3", path_type=PathType.softlink), PathData(_path="menu/test.json", path_type=PathType.hardlink) ] paths_data = PathsData(paths_version=0, paths=paths) package_info = PackageInfo( extracted_package_dir='/some/path', channel=Channel('defaults'), repodata_record=index_json_record, url='https://some.com/place/file.tar.bz2', index_json_record=index_json_record, icondata=icondata, package_metadata=package_metadata, paths_data=paths_data, ) self.assertIsInstance(package_info.paths_data.paths[0], PathData) self.assertIsInstance(package_info.index_json_record, IndexRecord) self.assertIsInstance(package_info.package_metadata.noarch, Noarch) assert package_info.paths_data.paths[0].path == "test/path/1"
def test_no_features(): # Without this, there would be another solution including 'scipy-0.11.0-np16py26_p3.tar.bz2'. assert r.install(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*'], returnall=True) == [[Dist(add_defaults_if_no_channel(fname)) for fname in [ 'numpy-1.6.2-py26_4.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-2.6.8-6.tar.bz2', 'readline-6.2-0.tar.bz2', 'scipy-0.11.0-np16py26_3.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]]] assert r.install(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*', 'mkl@'], returnall=True) == [[Dist(add_defaults_if_no_channel(fname)) for fname in [ 'mkl-rt-11.0-p0.tar.bz2', # This, 'numpy-1.6.2-py26_p4.tar.bz2', # this, 'openssl-1.0.1c-0.tar.bz2', 'python-2.6.8-6.tar.bz2', 'readline-6.2-0.tar.bz2', 'scipy-0.11.0-np16py26_p3.tar.bz2', # and this are different. 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]]] index2 = index.copy() index2["defaults::pandas-0.12.0-np16py27_0.tar.bz2"] = IndexRecord(**{ "build": "np16py27_0", "build_number": 0, "depends": [ "dateutil", "numpy 1.6*", "python 2.7*", "pytz" ], "name": "pandas", "requires": [ "dateutil 1.5", "numpy 1.6", "python 2.7", "pytz" ], "version": "0.12.0" }) # Make it want to choose the pro version by having it be newer. index2["defaults::numpy-1.6.2-py27_p5.tar.bz2"] = IndexRecord(**{ "build": "py27_p5", "build_number": 5, "depends": [ "mkl-rt 11.0", "python 2.7*" ], "features": "mkl", "name": "numpy", "pub_date": "2013-04-29", "requires": [ "mkl-rt 11.0", "python 2.7" ], "version": "1.6.2" }) index2 = {Dist(key): value for key, value in iteritems(index2)} r2 = Resolve(index2) # This should not pick any mkl packages (the difference here is that none # of the specs directly have mkl versions) assert r2.solve(['pandas 0.12.0 np16py27_0', 'python 2.7*'], returnall=True) == [[Dist(add_defaults_if_no_channel(fname)) for fname in [ 'dateutil-2.1-py27_1.tar.bz2', 'numpy-1.6.2-py27_4.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'pandas-0.12.0-np16py27_0.tar.bz2', 'python-2.7.5-0.tar.bz2', 'pytz-2013b-py27_0.tar.bz2', 'readline-6.2-0.tar.bz2', 'six-1.3.0-py27_0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]]] assert r2.solve(['pandas 0.12.0 np16py27_0', 'python 2.7*', 'mkl@'], returnall=True)[0] == [[Dist(add_defaults_if_no_channel(fname)) for fname in [ 'dateutil-2.1-py27_1.tar.bz2', 'mkl-rt-11.0-p0.tar.bz2', # This 'numpy-1.6.2-py27_p5.tar.bz2', # and this are different. 'openssl-1.0.1c-0.tar.bz2', 'pandas-0.12.0-np16py27_0.tar.bz2', 'python-2.7.5-0.tar.bz2', 'pytz-2013b-py27_0.tar.bz2', 'readline-6.2-0.tar.bz2', 'six-1.3.0-py27_0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]]][0]
def test_nonexistent_deps(): index2 = index.copy() index2['mypackage-1.0-py33_0.tar.bz2'] = IndexRecord(**{ 'build': 'py33_0', 'build_number': 0, 'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'], 'name': 'mypackage', 'requires': ['nose 1.2.1', 'python 3.3'], 'version': '1.0', }) index2['mypackage-1.1-py33_0.tar.bz2'] = IndexRecord(**{ 'build': 'py33_0', 'build_number': 0, 'depends': ['nose', 'python 3.3*'], 'name': 'mypackage', 'requires': ['nose 1.2.1', 'python 3.3'], 'version': '1.1', }) index2['anotherpackage-1.0-py33_0.tar.bz2'] = IndexRecord(**{ 'build': 'py33_0', 'build_number': 0, 'depends': ['nose', 'mypackage 1.1'], 'name': 'anotherpackage', 'requires': ['nose', 'mypackage 1.1'], 'version': '1.0', }) index2['anotherpackage-2.0-py33_0.tar.bz2'] = IndexRecord(**{ 'build': 'py33_0', 'build_number': 0, 'depends': ['nose', 'mypackage'], 'name': 'anotherpackage', 'requires': ['nose', 'mypackage'], 'version': '2.0', }) index2 = {Dist(key): value for key, value in iteritems(index2)} r = Resolve(index2) assert set(r.find_matches(MatchSpec('mypackage'))) == { Dist('mypackage-1.0-py33_0.tar.bz2'), Dist('mypackage-1.1-py33_0.tar.bz2'), } assert set(d.to_filename() for d in r.get_reduced_index(['mypackage']).keys()) == { 'mypackage-1.1-py33_0.tar.bz2', 'nose-1.1.2-py33_0.tar.bz2', 'nose-1.2.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-3.3.0-2.tar.bz2', 'python-3.3.0-3.tar.bz2', 'python-3.3.0-4.tar.bz2', 'python-3.3.0-pro0.tar.bz2', 'python-3.3.0-pro1.tar.bz2', 'python-3.3.1-0.tar.bz2', 'python-3.3.2-0.tar.bz2', 'readline-6.2-0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2'} target_result = r.install(['mypackage']) assert target_result == r.install(['mypackage 1.1']) assert target_result == [ Dist(add_defaults_if_no_channel(dname)) for dname in [ '<unknown>::mypackage-1.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-3.3.2-0.tar.bz2', 'readline-6.2-0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]] assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.0'])) assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.0', 'burgertime 1.0'])) assert r.install(['anotherpackage 1.0']) == [ Dist(add_defaults_if_no_channel(dname)) for dname in [ '<unknown>::anotherpackage-1.0-py33_0.tar.bz2', '<unknown>::mypackage-1.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-3.3.2-0.tar.bz2', 'readline-6.2-0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]] assert r.install(['anotherpackage']) == [ Dist(add_defaults_if_no_channel(dname)) for dname in [ '<unknown>::anotherpackage-2.0-py33_0.tar.bz2', '<unknown>::mypackage-1.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-3.3.2-0.tar.bz2', 'readline-6.2-0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]] # This time, the latest version is messed up index3 = index.copy() index3['mypackage-1.1-py33_0.tar.bz2'] = IndexRecord(**{ 'build': 'py33_0', 'build_number': 0, 'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'], 'name': 'mypackage', 'requires': ['nose 1.2.1', 'python 3.3'], 'version': '1.1', }) index3['mypackage-1.0-py33_0.tar.bz2'] = IndexRecord(**{ 'build': 'py33_0', 'build_number': 0, 'depends': ['nose', 'python 3.3*'], 'name': 'mypackage', 'requires': ['nose 1.2.1', 'python 3.3'], 'version': '1.0', }) index3['anotherpackage-1.0-py33_0.tar.bz2'] = IndexRecord(**{ 'build': 'py33_0', 'build_number': 0, 'depends': ['nose', 'mypackage 1.0'], 'name': 'anotherpackage', 'requires': ['nose', 'mypackage 1.0'], 'version': '1.0', }) index3['anotherpackage-2.0-py33_0.tar.bz2'] = IndexRecord(**{ 'build': 'py33_0', 'build_number': 0, 'depends': ['nose', 'mypackage'], 'name': 'anotherpackage', 'requires': ['nose', 'mypackage'], 'version': '2.0', }) index3 = {Dist(key): value for key, value in iteritems(index3)} r = Resolve(index3) assert set(d.to_filename() for d in r.find_matches(MatchSpec('mypackage'))) == { 'mypackage-1.0-py33_0.tar.bz2', 'mypackage-1.1-py33_0.tar.bz2', } assert set(d.to_filename() for d in r.get_reduced_index(['mypackage']).keys()) == { 'mypackage-1.0-py33_0.tar.bz2', 'nose-1.1.2-py33_0.tar.bz2', 'nose-1.2.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-3.3.0-2.tar.bz2', 'python-3.3.0-3.tar.bz2', 'python-3.3.0-4.tar.bz2', 'python-3.3.0-pro0.tar.bz2', 'python-3.3.0-pro1.tar.bz2', 'python-3.3.1-0.tar.bz2', 'python-3.3.2-0.tar.bz2', 'readline-6.2-0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2'} assert r.install(['mypackage']) == r.install(['mypackage 1.0']) == [ Dist(add_defaults_if_no_channel(dname)) for dname in [ '<unknown>::mypackage-1.0-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-3.3.2-0.tar.bz2', 'readline-6.2-0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]] assert raises(NoPackagesFoundError, lambda: r.install(['mypackage 1.1'])) assert r.install(['anotherpackage 1.0']) == [ Dist(add_defaults_if_no_channel(dname))for dname in [ '<unknown>::anotherpackage-1.0-py33_0.tar.bz2', '<unknown>::mypackage-1.0-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-3.3.2-0.tar.bz2', 'readline-6.2-0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]] # If recursive checking is working correctly, this will give # anotherpackage 2.0, not anotherpackage 1.0 assert r.install(['anotherpackage']) == [ Dist(add_defaults_if_no_channel(dname))for dname in [ '<unknown>::anotherpackage-2.0-py33_0.tar.bz2', '<unknown>::mypackage-1.0-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-0.tar.bz2', 'python-3.3.2-0.tar.bz2', 'readline-6.2-0.tar.bz2', 'sqlite-3.7.13-0.tar.bz2', 'system-5.8-1.tar.bz2', 'tk-8.5.13-0.tar.bz2', 'zlib-1.2.7-0.tar.bz2', ]]
from conda.models.match_spec import MatchSpec from conda.plan import display_actions import conda.plan as plan from conda.resolve import Resolve from conda.utils import on_win from .decorators import skip_if_no_mock from .gateways.disk.test_permissions import tempdir from .helpers import captured, mock, tempdir try: from unittest.mock import patch except ImportError: from mock import patch with open(join(dirname(__file__), 'index.json')) as fi: index = {Dist(k): IndexRecord(**v) for k, v in iteritems(json.load(fi))} r = Resolve(index) def solve(specs): return [Dist.from_string(fn) for fn in r.solve(specs)] class add_unlink_TestCase(unittest.TestCase): def generate_random_dist(self): return "foobar-%s-0" % random.randint(100, 200) @contextmanager def mock_platform(self, windows=False): with mock.patch.object(plan, "sys") as sys: sys.platform = "win32" if windows else "not win32"
from conda.common.compat import iteritems, text_type from conda.exceptions import NoPackagesFoundError, UnsatisfiableError from conda.models.dist import Dist from conda.models.index_record import IndexRecord from conda.resolve import MatchSpec, Resolve from conda.models.package import Package from os.path import dirname, join import pytest from conda.resolve import MatchSpec, Package, Resolve, NoPackagesFound, Unsatisfiable from tests.helpers import raises with open(join(dirname(__file__), 'index.json')) as fi: index = { Dist(key): IndexRecord(**value) for key, value in iteritems(json.load(fi)) } r = Resolve(index) f_mkl = set(['mkl']) class TestMatchSpec(unittest.TestCase): def test_match(self): for spec, res in [ ('numpy 1.7*', True), ('numpy 1.7.1', True), ('numpy 1.7', False), ('numpy 1.5*', False),
from conda.base.constants import MAX_CHANNEL_PRIORITY from conda.base.context import reset_context from conda.common.compat import iteritems, text_type from conda.exceptions import NoPackagesFoundError, UnsatisfiableError from conda.models.dist import Dist from conda.models.index_record import IndexRecord from conda.resolve import MatchSpec, Resolve from os.path import dirname, join import pytest from conda.resolve import MatchSpec, Resolve, NoPackagesFound, Unsatisfiable from tests.helpers import raises with open(join(dirname(__file__), 'index.json')) as fi: index = {Dist(key): IndexRecord(**value) for key, value in iteritems(json.load(fi))} r = Resolve(index) f_mkl = set(['mkl']) class TestMatchSpec(unittest.TestCase): def test_match(self): for spec, res in [ ('numpy 1.7*', True), ('numpy 1.7.1', True), ('numpy 1.7', False), ('numpy 1.5*', False), ('numpy >=1.5', True), ('numpy >=1.5,<2', True), ('numpy >=1.8,<1.9', False), ('numpy >1.5,<2,!=1.7.1', False), ('numpy >1.8,<2|==1.7', False),('numpy >1.8,<2|>=1.7.1', True),