def test_py_version_selector(self): meta = self.write_meta(""" package: name: recipe_which_depends_on_py_version version: 3 # [py3k] version: 2 # [not py3k] """) dist1 = ResolvedDistribution(meta, (('python', '27', ), )) dist2 = ResolvedDistribution(meta, (('python', '35', ), )) self.assertEqual(dist1.version(), u'2') self.assertEqual(dist2.version(), u'3')
def test(self): # Build a recipe. py2 = self.write_meta('py1', """ package: name: python version: 1.2.3 """) py2 = self.write_meta('py2', """ package: name: python version: 2.1.10 """) a = self.write_meta('a', """ package: name: a version: 3.1.4 requirements: build: - python run: - python """) a_py12 = ResolvedDistribution(a, (('python', '12', ), )) a_py21 = ResolvedDistribution(a, (('python', '21', ), )) a_py99 = ResolvedDistribution(a, (('python', '99', ), )) testing_channel = '{}/channel/{}'.format(OWNER, 'testing') self.call([self.recipes_root_dir, '--upload-channel', testing_channel]) # Check that we have started on the right footing - the distribution should be on testing, # but not on main. self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, py2, channel='testing')) self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, py2, channel='main')) # Check that we've had a py21 and py12, but not a py99 for a. self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, a_py12, channel='testing')) self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing')) self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, a_py99, channel='testing')) # Remove the built distribution, re-run, and assert that we didn't bother re-building. dist_path = os.path.join(self.conda_bld_root, conda.config.subdir, a_py21.pkg_fn()) self.assertTrue(os.path.exists(dist_path)) os.remove(dist_path) self.call([self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel]) self.assertFalse(os.path.exists(dist_path)) # Now put a condition in. In this case, only build dists for py<2 CLIENT.remove_dist(OWNER, a_py21.name(), a_py21.version(), '{}/{}'.format(conda.config.subdir, a_py21.pkg_fn())) self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing')) self.call([self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel, '--matrix-condition', 'python <2']) self.assertFalse(distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing')) self.assertFalse(os.path.exists(dist_path)) # Without the condition, we should be re-building the distribution self.call([self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel]) self.assertTrue(os.path.exists(dist_path)) self.assertTrue(distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing'))
def test(self): # Build a recipe. py2 = self.write_meta( 'py1', """ package: name: python version: 1.2.3 """) py2 = self.write_meta( 'py2', """ package: name: python version: 2.1.10 """) a = self.write_meta( 'a', """ package: name: a version: 3.1.4 requirements: build: - python run: - python """) a_py12 = ResolvedDistribution(a, (( 'python', '12', ), )) a_py21 = ResolvedDistribution(a, (( 'python', '21', ), )) a_py99 = ResolvedDistribution(a, (( 'python', '99', ), )) testing_channel = '{}/channel/{}'.format(OWNER, 'testing') self.call([self.recipes_root_dir, '--upload-channel', testing_channel]) # Check that we have started on the right footing - the distribution should be on testing, # but not on main. self.assertTrue( distribution_exists_on_channel(CLIENT, OWNER, py2, channel='testing')) self.assertFalse( distribution_exists_on_channel(CLIENT, OWNER, py2, channel='main')) # Check that we've had a py21 and py12, but not a py99 for a. self.assertTrue( distribution_exists_on_channel(CLIENT, OWNER, a_py12, channel='testing')) self.assertTrue( distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing')) self.assertFalse( distribution_exists_on_channel(CLIENT, OWNER, a_py99, channel='testing')) # Remove the built distribution, re-run, and assert that we didn't bother re-building. dist_path = os.path.join(self.conda_bld_root, conda.config.subdir, a_py21.pkg_fn()) self.assertTrue(os.path.exists(dist_path)) os.remove(dist_path) self.call([ self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel ]) self.assertFalse(os.path.exists(dist_path)) # Now put a condition in. In this case, only build dists for py<2 CLIENT.remove_dist( OWNER, a_py21.name(), a_py21.version(), '{}/{}'.format(conda.config.subdir, a_py21.pkg_fn())) self.assertFalse( distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing')) self.call([ self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel, '--matrix-condition', 'python <2' ]) self.assertFalse( distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing')) self.assertFalse(os.path.exists(dist_path)) # Without the condition, we should be re-building the distribution self.call([ self.recipes_root_dir, '--inspect-channel', testing_channel, '--upload-channel', testing_channel ]) self.assertTrue(os.path.exists(dist_path)) self.assertTrue( distribution_exists_on_channel(CLIENT, OWNER, a_py21, channel='testing'))