Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test(self):
self.write_build_file("""
from pybuilder.core import task
@task
def spam (): pass
""")
reactor = self.prepare_reactor()
self.assertRaises(PyBuilderException, reactor.build)
from pybuilder.core import init, use_plugin
@init
def initialize(project):
project.set_property("run_unit_tests_propagate_stdout", True)
project.set_property("run_unit_tests_propagate_stderr", True)
project.set_property('verbose', True)
use_plugin("exec")
use_plugin("python.core")
use_plugin("python.unittest")
use_plugin('python.install_dependencies')
use_plugin('python.integrationtest')
default_task = ['clean']
@task("any-task-name")
@description("any-description")
def task_with_description():
pass
@task
def task1():
pass
def test_should_unwrap_single_list(self):
self.assertEquals(["spam", "eggs"], as_list(["spam", "eggs"]))
def test_ensure_that_dependencies_are_resolved_when_simple_dependency_is_found(self):
one = Mock(name="one", dependencies=[])
two = Mock(name="two", dependencies=[TaskDependency("one")])
self.execution_manager.register_task(one, two)
self.execution_manager.resolve_dependencies()
self.assertEqual([], self.execution_manager._task_dependencies.get("one"))
self.assertEqual([TaskDependency(one)], self.execution_manager._task_dependencies.get("two"))
def test_should_collect_all_tasks_when_there_is_a_transitive_dependency(self):
one = Mock(name="one", dependencies=[TaskDependency("two")])
two = Mock(name="two", dependencies=[TaskDependency("three")])
three = Mock(name="three", dependencies=[])
self.execution_manager.register_task(one, two, three)
self.execution_manager.resolve_dependencies()
self.assertEqual(self.execution_manager.collect_all_transitive_tasks(["one"]), set([one, two, three]))
def test_is_task_in_current_execution_plan(self):
one = Mock(name="one", dependencies=[])
two = Mock(name="two", dependencies=[TaskDependency("one")])
three = Mock(name="three", dependencies=[TaskDependency("one"), TaskDependency("two")])
self.execution_manager.register_task(one, two, three)
self.execution_manager.resolve_dependencies(exclude_all_optional=True)
self.execution_manager._current_execution_plan = self.execution_manager.build_execution_plan("three")
self.assertTrue(self.execution_manager.is_task_in_current_execution_plan("three"))
self.assertTrue(self.execution_manager.is_task_in_current_execution_plan("two"))
self.assertTrue(self.execution_manager.is_task_in_current_execution_plan("one"))
self.assertFalse(self.execution_manager.is_task_in_current_execution_plan("four"))
def test_shortest_execution_plan_reruns_on_demand(self):
one = Mock(name="one", dependencies=[])
two = Mock(name="two", dependencies=[TaskDependency("one")])
three = Mock(name="three", dependencies=[TaskDependency("two")])
self.execution_manager.register_task(one, two, three)
self.execution_manager.resolve_dependencies()
self.execution_manager._tasks_executed.append(one)
self.execution_manager._tasks_executed.append(two)
self.assertEqual([two, three], self.execution_manager.build_shortest_execution_plan(("two", "three")))
self.assertEqual([two, three], self.execution_manager.build_shortest_execution_plan(("three", "two")))
self.assertEqual([one, two, three], self.execution_manager.build_shortest_execution_plan(("three", "one")))
def test_verify_error_unresolved_late_dependency(self):
one = Mock(name="one", dependencies=[])
two = Mock(name="two", dependencies=[TaskDependency("one")])
three = Mock(name="three", dependencies=[TaskDependency("one")])
self.execution_manager.register_task(one, two)
self.execution_manager.register_task(three)
self.execution_manager.register_late_task_dependencies(
{"four": [TaskDependency("three")]})
self.assertRaises(NoSuchTaskException, self.execution_manager.resolve_dependencies)