def setUp(self):
     self.index = DummyIndex()
     self.recipe_dir = tempfile.mkdtemp(prefix='tmp_obvci_recipe_')
 def setUp(self):
     self.index = DummyIndex()
     self.recipe_dir = tempfile.mkdtemp(prefix='tmp_obvci_recipe_')
class Test_baked_version(unittest.TestCase):
    def setUp(self):
        self.index = DummyIndex()
        self.recipe_dir = tempfile.mkdtemp(prefix='tmp_obvci_recipe_')

    def tearDown(self):
        shutil.rmtree(self.recipe_dir)

    def test_py_xx_version(self):
        recipe = """
            package:
                name: recipe_which_depends_on_py_version
                version: 2
            requirements:
                build:
                 - python >=2.7
                 - numpy
                run:
                 - python x.x
                 - numpy x.x
            """
        with open(os.path.join(self.recipe_dir, 'meta.yaml'), 'w') as fh:
            fh.write(recipe)
        conda_build.config.config.CONDA_PY = 35
        conda_build.config.config.CONDA_NPY = 17

        meta = MetaData(self.recipe_dir)

        self.index.add_pkg('python', '2.7.2')
        self.index.add_pkg('python', '2.6.2')
        self.index.add_pkg('python', '3.5.0')
        self.index.add_pkg('numpy', '1.8.0', depends=['python'])
        r = BakedDistribution.compute_matrix(meta, self.index)
        self.assertEqual(len(r), 2)
        self.assertEqual(r[0].build_id(), 'np18py27_0')
        self.assertEqual(r[1].build_id(), 'np18py35_0')

    def test_py_xx_version(self):
        recipe = """
            package:
                name: recipe_which_depends_on_py_version
                version: 2
            build:
                skip: True  # [py3k]
            requirements:
                build:
                    - python
                run:
                    - python
            """
        with open(os.path.join(self.recipe_dir, 'meta.yaml'), 'w') as fh:
            fh.write(recipe)
        conda_build.config.config.CONDA_PY = 35

        meta = MetaData(self.recipe_dir)

        self.index.add_pkg('python', '2.7.2')
        self.index.add_pkg('python', '2.6.2')
        self.index.add_pkg('python', '3.5.0')
        r = BakedDistribution.compute_matrix(meta, self.index)
        self.assertEqual(len(r), 2)
        self.assertEqual(r[0].build_id(), 'py27_0')
        self.assertEqual(r[1].build_id(), 'py26_0')
class Test_baked_version(unittest.TestCase):
    def setUp(self):
        self.index = DummyIndex()
        self.recipe_dir = tempfile.mkdtemp(prefix='tmp_obvci_recipe_')

    def tearDown(self):
        shutil.rmtree(self.recipe_dir)

    def test_py_xx_version(self):
        recipe = """
            package:
                name: recipe_which_depends_on_py_version
                version: 2
            requirements:
                build:
                 - python >=2.7
                 - numpy
                run:
                 - python x.x
                 - numpy x.x
            """
        with open(os.path.join(self.recipe_dir, 'meta.yaml'), 'w') as fh:
            fh.write(recipe)
        conda_build.config.config.CONDA_PY = 35
        conda_build.config.config.CONDA_NPY = 17

        meta = MetaData(self.recipe_dir)

        self.index.add_pkg('python', '2.7.2')
        self.index.add_pkg('python', '2.6.2')
        self.index.add_pkg('python', '3.5.0')
        self.index.add_pkg('numpy', '1.8.0', depends=['python'])
        r = BakedDistribution.compute_matrix(meta, self.index)
        self.assertEqual(len(r), 2)
        self.assertEqual(r[0].build_id(), 'np18py27_0')
        self.assertEqual(r[1].build_id(), 'np18py35_0')

    def test_py_xx_version(self):
        recipe = """
            package:
                name: recipe_which_depends_on_py_version
                version: 2
            build:
                skip: True  # [py3k]
            requirements:
                build:
                    - python
                run:
                    - python
            """
        with open(os.path.join(self.recipe_dir, 'meta.yaml'), 'w') as fh:
            fh.write(recipe)
        conda_build.config.config.CONDA_PY = 35

        meta = MetaData(self.recipe_dir)

        self.index.add_pkg('python', '2.7.2')
        self.index.add_pkg('python', '2.6.2')
        self.index.add_pkg('python', '3.5.0')
        r = BakedDistribution.compute_matrix(meta, self.index)
        self.assertEqual(len(r), 2)
        self.assertEqual(r[0].build_id(), 'py27_0')
        self.assertEqual(r[1].build_id(), 'py26_0')