From 34438b38241750f4feace6b6b75b59da2bc2fcfd Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Thu, 25 Dec 2014 18:51:04 +0100 Subject: [PATCH] tests: Make tests Python 2.6 compatible, avoid using assertRaises as context manager --- tasklib/tests.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/tasklib/tests.py b/tasklib/tests.py index 2af697f..2103c06 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -77,44 +77,41 @@ class TaskTest(TasklibTest): t = Task(self.tw, description="test task") self.assertEqual(len(self.tw.tasks.all()), 0) + # TODO: once python 2.6 compatiblity is over, use context managers here + # and in all subsequent tests for assertRaises + def test_delete_unsaved_task(self): - with self.assertRaises(Task.NotSaved): - t = Task(self.tw, description="test task") - t.delete() + t = Task(self.tw, description="test task") + self.assertRaises(Task.NotSaved, t.delete) def test_complete_unsaved_task(self): - with self.assertRaises(Task.NotSaved): - t = Task(self.tw, description="test task") - t.done() + t = Task(self.tw, description="test task") + self.assertRaises(Task.NotSaved, t.done) def test_refresh_unsaved_task(self): - with self.assertRaises(Task.NotSaved): - t = Task(self.tw, description="test task") - t.refresh() + t = Task(self.tw, description="test task") + self.assertRaises(Task.NotSaved, t.refresh) def test_delete_deleted_task(self): t = Task(self.tw, description="test task") t.save() t.delete() - with self.assertRaises(Task.DeletedTask): - t.delete() + self.assertRaises(Task.DeletedTask, t.delete) def test_complete_completed_task(self): t = Task(self.tw, description="test task") t.save() t.done() - with self.assertRaises(Task.CompletedTask): - t.done() + self.assertRaises(Task.CompletedTask, t.done) def test_complete_deleted_task(self): t = Task(self.tw, description="test task") t.save() t.delete() - with self.assertRaises(Task.DeletedTask): - t.done() + self.assertRaises(Task.DeletedTask, t.done) class AnnotationTest(TasklibTest): -- 2.39.5