按最新版的pytest测试框架。
如果只是单一的mark,不要加任何引号。
如果是要作and ,not之类的先把,一定要是双引号!
这个要记清楚,好像和以前版本的书上介绍的不一样,切记!
import pytest import tasks @pytest.mark.smoke def test_list_raises(): with pytest.raises(TypeError): tasks.list_tasks(owner=123) @pytest.mark.get @pytest.mark.smoke def test_get_raises(): with pytest.raises(TypeError): tasks.get(task_id=') def test_add_raises(): with pytest.raises(TypeError): tasks.add(task="not a task object") def test_start_db_raises(): with pytest.raises(ValueError) as excinfo: tasks.start_tasks_db('some/great/path', 'mysql') exception_msg = excinfo.value.args[0] assert exception_msg == "db_type must be a 'tiny' or 'mongo'"