# tests/test_example.py import pytest import time class TestExample: """示例测试类""" def test_addition(self): """测试加法运算""" assert 1 + 1 == 2 def test_subtraction(self): """测试减法运算""" assert 5 - 3 == 2 def test_failure_example(self): """这是一个会失败的测试示例""" assert 5 == 6, "数字不相等" @pytest.mark.skip(reason="示例跳过测试") def test_skip_example(self): """这是一个跳过的测试示例""" assert True class TestWebExample: """Web 测试示例""" def test_web_title(self, driver): """测试网页标题""" driver.get("https://baidu.com") assert "Example" in driver.title def test_web_content(self, driver): """测试网页内容""" driver.get("https://baidu.com") content = driver.find_element_by_tag_name("body").text assert "example" in content.lower() def test_chinese_content(self): """测试中文字符""" chinese_text = "这是一段中文测试文本" assert "中文" in chinese_text