def test_validation(self): with ParseContext.temp('PythonTargetTest/test_validation'): # Adding a JVM Artifact as a provides on a PythonTarget doesn't make a lot of sense. This test # sets up that very scenario, and verifies that pants throws a TargetDefinitionException. self.assertRaises(TargetDefinitionException, PythonTarget, name="one", sources=[], provides=Artifact(org='com.twitter', name='one-jar', repo=Repository( name='internal', url=None, push_db=None, exclusives=None))) name = "test-with-PythonArtifact" pa = PythonArtifact(name='foo', version='1.0', description='foo') # This test verifies that adding a 'setup_py' provides to a PythonTarget is okay. self.assertEquals( PythonTarget(name=name, provides=pa, sources=[]).name, name) name = "test-with-none" # This test verifies that having no provides is okay. self.assertEquals( PythonTarget(name=name, provides=None, sources=[]).name, name)