From a61472e331bc001eb3790cb1f1a4329c354f79f6 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Fri, 30 Oct 2020 16:13:06 +0800 Subject: [PATCH] add test case --- test/example.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 test/example.py diff --git a/test/example.py b/test/example.py new file mode 100644 index 0000000..22cc4df --- /dev/null +++ b/test/example.py @@ -0,0 +1,61 @@ +#/bin/env python3 +#-*- encoding=utf8 -*- +""" +create by: miaokaibo +date: 2020-10-30 + +test all: pytest -s example.py --html=result.html +test one class: pytest -s xxxx.py::Testxx --html=result.html +test one class one case: pytest -s xxxx.py::Testxx::test_xxx --html=result.html +""" +import pytest + + +class TestCase(object): + def setup_class(self): + """ + setup before all cases + """ + print("setup_class") + + def teardown_class(self): + """ + teardown after all cases + """ + print("teardown_class") + + def setup_method(self): + """ + setup before everyone case + """ + print("setup_method") + + def teardown_method(self): + """ + teardown after everyone case + """ + print("teardown_method") + + def test_1(self): + """ + case name must start with test_ + """ + print("test_1") + assert False + + def test_2(self): + """ + case name must start with test_ + """ + print("test_2") + assert True + + def test_3(self): + """ + case name must start with test_ + """ + print("test_3") + assert True + +#if __main__ == "__name__": + -- Gitee