Skip to content

Commit 78b59a0

Browse files
authored
Implement mkdocs serve command test
Add a test for mkdocs serve command functionality
1 parent ff94974 commit 78b59a0

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
import sys
3+
import pytest
4+
import time
5+
6+
def test_mkdocs_serve():
7+
"""
8+
检查mkdocs serve命令是否正常工作
9+
"""
10+
os.system("mkdocs serve -a 127.0.0.1:6007 -f ../../mkdocs.yml >test_mkdocs_serve.log 2>&1 &")
11+
time.sleep(50)
12+
with open("test_mkdocs_serve.log", 'r') as file:
13+
log_content = file.read()
14+
assert "WARNING" not in log_content and "ERROR" not in log_content
15+
16+
if __name__ == '__main__':
17+
# 使用 pytest 模块运行测试函数
18+
code = pytest.main([sys.argv[0]])
19+
sys.exit(code)

0 commit comments

Comments
 (0)