def test_copy_accepts_task_args(self): t = Task() t2 = t.copy(name="new-task") t3 = t.copy(**{"max_retries": 4200}) assert t2.name == "new-task" assert t3.max_retries == 4200
def test_copy_warns_if_dependencies_in_active_flow(self): t1 = Task() t2 = Task() with Flow(name="test"): t1.set_dependencies(downstream_tasks=[t2]) with pytest.warns(UserWarning): t1.copy() with Flow(name="test"): # no dependencies in this flow t1.copy()
def test_copy_warns_if_dependencies_in_active_flow(self): t1 = Task() t2 = Task() with Flow(name="test") as flow: t1.set_dependencies(downstream_tasks=[t2]) with pytest.warns(UserWarning, match="You are making a copy"): flow.add_task(t1.copy()) with Flow(name="test") as flow: with pytest.warns(None) as rec: flow.add_task(t1.copy()) # no dependencies in this flow assert len(rec) == 0
def test_copying_then_setting_tags_doesnt_leak_backwards(): with Flow(name="test"): t1 = Task() with tasks.tags("init-tag"): t2 = t1.copy() assert t2.tags == {"init-tag"} assert t1.tags == set()
def test_copy_accepts_slug_as_task_args(self): t = Task(slug="test") t2 = t.copy(slug="test-2") assert t.slug == "test" assert t2.slug == "test-2"
def test_copy_changes_slug(self): t1 = Task(slug="test") t2 = t1.copy() assert t1.slug == "test" assert t1.slug != t2.slug
def test_copy_changes_id(self): t1 = Task() t2 = t1.copy() assert t1.id != t2.id