def test_parse_build_number_brackets(self): assert _parse_spec_str("python[build_number=3]") == { "_original_spec_str": "python[build_number=3]", "name": "python", "build_number": '3', } assert _parse_spec_str("python[build_number='>3']") == { "_original_spec_str": "python[build_number='>3']", "name": "python", "build_number": '>3', } assert _parse_spec_str("python[build_number='>=3']") == { "_original_spec_str": "python[build_number='>=3']", "name": "python", "build_number": '>=3', } assert _parse_spec_str("python[build_number='<3']") == { "_original_spec_str": "python[build_number='<3']", "name": "python", "build_number": '<3', } assert _parse_spec_str("python[build_number='<=3']") == { "_original_spec_str": "python[build_number='<=3']", "name": "python", "build_number": '<=3', }
def test_parse_spec_str_tarball_url(self): with env_unmodified(conda_tests_ctxt_mgmt_def_pol): url = "https://repo.anaconda.com/pkgs/main/linux-64/_license-1.1-py27_1.tar.bz2" assert _parse_spec_str(url) == { "channel": "defaults", "subdir": "linux-64", "name": "_license", "version": "1.1", "build": "py27_1", "fn": "_license-1.1-py27_1.tar.bz2", "url": url, } url = "https://conda.anaconda.org/conda-canary/linux-64/conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2" assert _parse_spec_str(url) == { "channel": "conda-canary", "subdir": "linux-64", "name": "conda", "version": "4.3.21.post699+1dab973", "build": "py36h4a561cd_0", "fn": "conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2", "url": url, } url = "https://conda.anaconda.org/conda-canary/linux-64/conda-4.3.21.post699+1dab973-py36h4a561cd_0.conda" assert _parse_spec_str(url) == { "channel": "conda-canary", "subdir": "linux-64", "name": "conda", "version": "4.3.21.post699+1dab973", "build": "py36h4a561cd_0", "fn": "conda-4.3.21.post699+1dab973-py36h4a561cd_0.conda", "url": url, }
def test_parse_spec_str_with_brackets(self): assert _parse_spec_str("defaults::numpy[channel=anaconda]") == { "_original_spec_str": "defaults::numpy[channel=anaconda]", "channel": "anaconda", "name": "numpy", } assert _parse_spec_str( "defaults::numpy 1.8 py27_0[channel=anaconda]") == { "_original_spec_str": "defaults::numpy 1.8 py27_0[channel=anaconda]", "channel": "anaconda", "name": "numpy", "version": "1.8", "build": "py27_0", } assert _parse_spec_str( "defaults::numpy=1.8=py27_0 [channel=anaconda,version=1.9, build=3]" ) == { "_original_spec_str": "defaults::numpy=1.8=py27_0 [channel=anaconda,version=1.9, build=3]", "channel": "anaconda", "name": "numpy", "version": "1.9", "build": "3", } assert _parse_spec_str( 'defaults::numpy=1.8=py27_0 [channel=\'anaconda\',version=">=1.8,<2|1.9", build=\'3\']' ) == { "_original_spec_str": 'defaults::numpy=1.8=py27_0 [channel=\'anaconda\',version=">=1.8,<2|1.9", build=\'3\']', "channel": "anaconda", "name": "numpy", "version": ">=1.8,<2|1.9", "build": "3", }
def test_parse_equal_equal(self): assert _parse_spec_str("numpy==1.7") == { "_original_spec_str": "numpy==1.7", "name": "numpy", "version": "1.7", } assert _parse_spec_str("numpy ==1.7") == { "_original_spec_str": "numpy ==1.7", "name": "numpy", "version": "1.7", } assert _parse_spec_str("numpy=1.7") == { "_original_spec_str": "numpy=1.7", "name": "numpy", "version": "1.7*", } assert _parse_spec_str("numpy =1.7") == { "_original_spec_str": "numpy =1.7", "name": "numpy", "version": "1.7*", } assert _parse_spec_str("numpy !=1.7") == { "_original_spec_str": "numpy !=1.7", "name": "numpy", "version": "!=1.7", }
def test_parse_spec_str_with_brackets(self): assert _parse_spec_str("defaults::numpy[channel=anaconda]") == { "_original_spec_str": "defaults::numpy[channel=anaconda]", "channel": "anaconda", "name": "numpy", } assert _parse_spec_str("defaults::numpy 1.8 py27_0[channel=anaconda]") == { "_original_spec_str": "defaults::numpy 1.8 py27_0[channel=anaconda]", "channel": "anaconda", "name": "numpy", "version": "1.8", "build": "py27_0", } assert _parse_spec_str("defaults::numpy=1.8=py27_0 [channel=anaconda,version=1.9, build=3]") == { "_original_spec_str": "defaults::numpy=1.8=py27_0 [channel=anaconda,version=1.9, build=3]", "channel": "anaconda", "name": "numpy", "version": "1.9", "build": "3", } assert _parse_spec_str('defaults::numpy=1.8=py27_0 [channel=\'anaconda\',version=">=1.8,<2|1.9", build=\'3\']') == { "_original_spec_str": 'defaults::numpy=1.8=py27_0 [channel=\'anaconda\',version=">=1.8,<2|1.9", build=\'3\']', "channel": "anaconda", "name": "numpy", "version": ">=1.8,<2|1.9", "build": "3", }
def test_parse_equal_equal(self): assert _parse_spec_str("numpy==1.7") == { "name": "numpy", "version": "1.7", } assert _parse_spec_str("numpy ==1.7") == { "name": "numpy", "version": "1.7", }
def test_star_name(self): assert _parse_spec_str("* 2.7.4") == { "name": "*", "version": "2.7.4", } assert _parse_spec_str("* >=1.3 2") == { "name": "*", "version": ">=1.3", "build": "2", }
def test_parse_parens(self): assert _parse_spec_str("conda-forge::foo[build=3](target=blarg,optional)") == { "channel": "conda-forge", "name": "foo", "build": "3", # "target": "blarg", # suppressing these for now # "optional": True, }
def test_parse_hard(self): assert _parse_spec_str("numpy~=1.7.1") == { "_original_spec_str": "numpy~=1.7.1", "name": "numpy", "version": "~=1.7.1", } assert _parse_spec_str("numpy>1.8,<2|==1.7") == { "_original_spec_str": "numpy>1.8,<2|==1.7", "name": "numpy", "version": ">1.8,<2|==1.7", } assert _parse_spec_str("numpy >1.8,<2|==1.7,!=1.9,~=1.7.1 py34_0") == { "_original_spec_str": "numpy >1.8,<2|==1.7,!=1.9,~=1.7.1 py34_0", "name": "numpy", "version": ">1.8,<2|==1.7,!=1.9,~=1.7.1", "build": "py34_0", } assert _parse_spec_str("*>1.8,<2|==1.7") == { "_original_spec_str": "*>1.8,<2|==1.7", "name": "*", "version": ">1.8,<2|==1.7", } assert _parse_spec_str("* >1.8,<2|==1.7") == { "_original_spec_str": "* >1.8,<2|==1.7", "name": "*", "version": ">1.8,<2|==1.7", } assert _parse_spec_str("* 1 *") == { "_original_spec_str": "* 1 *", "name": "*", "version": "1", "build": "*", } assert _parse_spec_str("* * openblas_0") == { "_original_spec_str": "* * openblas_0", "name": "*", "version": "*", "build": "openblas_0", } assert _parse_spec_str("* * *") == { "_original_spec_str": "* * *", "name": "*", "version": "*", "build": "*", } assert _parse_spec_str("* *") == { "_original_spec_str": "* *", "name": "*", "version": "*", }
def test_parse_channel_subdir(self): assert _parse_spec_str("conda-forge::foo>=1.0") == { "channel": "conda-forge", "name": "foo", "version": ">=1.0", } assert _parse_spec_str("conda-forge/linux-32::foo>=1.0") == { "channel": "conda-forge", "subdir": "linux-32", "name": "foo", "version": ">=1.0", } assert _parse_spec_str("*/linux-32::foo>=1.0") == { "channel": "*", "subdir": "linux-32", "name": "foo", "version": ">=1.0", }
def test_parse_spec_str_tarball_url(self): url = "https://repo.continuum.io/pkgs/free/linux-64/_license-1.1-py27_1.tar.bz2" assert _parse_spec_str(url) == { "channel": "defaults", "subdir": "linux-64", "name": "_license", "version": "1.1", "build": "py27_1", "fn": "_license-1.1-py27_1.tar.bz2", "url": url, } url = "https://conda.anaconda.org/conda-canary/linux-64/conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2" assert _parse_spec_str(url) == { "channel": "conda-canary", "subdir": "linux-64", "name": "conda", "version": "4.3.21.post699+1dab973", "build": "py36h4a561cd_0", "fn": "conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2", "url": url, }
def test_parse_spec_str_no_brackets(self): assert _parse_spec_str("numpy") == { "_original_spec_str": "numpy", "name": "numpy", } assert _parse_spec_str("defaults::numpy") == { "_original_spec_str": "defaults::numpy", "channel": "defaults", "name": "numpy", } assert _parse_spec_str( "https://repo.anaconda.com/pkgs/free::numpy") == { "_original_spec_str": "https://repo.anaconda.com/pkgs/free::numpy", "channel": "pkgs/free", "name": "numpy", } assert _parse_spec_str("defaults::numpy=1.8") == { "_original_spec_str": "defaults::numpy=1.8", "channel": "defaults", "name": "numpy", "version": "1.8*", } assert _parse_spec_str("defaults::numpy =1.8") == { "_original_spec_str": "defaults::numpy =1.8", "channel": "defaults", "name": "numpy", "version": "1.8*", } assert _parse_spec_str("defaults::numpy=1.8=py27_0") == { "_original_spec_str": "defaults::numpy=1.8=py27_0", "channel": "defaults", "name": "numpy", "version": "1.8", "build": "py27_0", } assert _parse_spec_str("defaults::numpy 1.8 py27_0") == { "_original_spec_str": "defaults::numpy 1.8 py27_0", "channel": "defaults", "name": "numpy", "version": "1.8", "build": "py27_0", }
def test_parse_hard(self): assert _parse_spec_str("numpy>1.8,<2|==1.7") == { "name": "numpy", "version": ">1.8,<2|==1.7", } assert _parse_spec_str("numpy >1.8,<2|==1.7") == { "name": "numpy", "version": ">1.8,<2|==1.7", } assert _parse_spec_str("*>1.8,<2|==1.7") == { "name": "*", "version": ">1.8,<2|==1.7", } assert _parse_spec_str("* >1.8,<2|==1.7") == { "name": "*", "version": ">1.8,<2|==1.7", } assert _parse_spec_str("* 1 *") == { "name": "*", "version": "1", "build": "*", } assert _parse_spec_str("* * openblas_0") == { "name": "*", "version": "*", "build": "openblas_0", } assert _parse_spec_str("* * *") == { "name": "*", "version": "*", "build": "*", } assert _parse_spec_str("* *") == { "name": "*", "version": "*", }
def test_parse_spec_str_no_brackets(self): assert _parse_spec_str("numpy") == { "_original_spec_str": "numpy", "name": "numpy", } assert _parse_spec_str("defaults::numpy") == { "_original_spec_str": "defaults::numpy", "channel": "defaults", "name": "numpy", } assert _parse_spec_str("https://repo.anaconda.com/pkgs/free::numpy") == { "_original_spec_str": "https://repo.anaconda.com/pkgs/free::numpy", "channel": "pkgs/free", "name": "numpy", } assert _parse_spec_str("defaults::numpy=1.8") == { "_original_spec_str": "defaults::numpy=1.8", "channel": "defaults", "name": "numpy", "version": "1.8*", } assert _parse_spec_str("defaults::numpy =1.8") == { "_original_spec_str": "defaults::numpy =1.8", "channel": "defaults", "name": "numpy", "version": "1.8*", } assert _parse_spec_str("defaults::numpy=1.8=py27_0") == { "_original_spec_str": "defaults::numpy=1.8=py27_0", "channel": "defaults", "name": "numpy", "version": "1.8", "build": "py27_0", } assert _parse_spec_str("defaults::numpy 1.8 py27_0") == { "_original_spec_str": "defaults::numpy 1.8 py27_0", "channel": "defaults", "name": "numpy", "version": "1.8", "build": "py27_0", }
def test_parse_spec_str_no_brackets(self): assert _parse_spec_str("numpy") == { "name": "numpy", } assert _parse_spec_str("defaults::numpy") == { "channel": "defaults", "name": "numpy", } assert _parse_spec_str("https://repo.continuum.io/pkgs/free::numpy") == { "channel": "defaults", "name": "numpy", } assert _parse_spec_str("defaults::numpy=1.8") == { "channel": "defaults", "name": "numpy", "version": "1.8*", } == _parse_spec_str("defaults::numpy =1.8") assert _parse_spec_str("defaults::numpy=1.8=py27_0") == { "channel": "defaults", "name": "numpy", "version": "1.8", "build": "py27_0", } == _parse_spec_str("defaults::numpy 1.8 py27_0")
def test_parse_errors(self): with pytest.raises(InvalidMatchSpec): _parse_spec_str('!xyz 1.3')
def test_parse_errors(self): with pytest.raises(CondaValueError): _parse_spec_str('!xyz 1.3')