codesp.py 1.46 KB
Newer Older
qiongying.jia's avatar
qiongying.jia committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import jinja2
#this is test message
#another
def test():
    try:
      
        template = jinja2.Template("Hello {{ name }}!")
        assert template.render(name="World") == "Hello World!"
        print("✅ Jinja2 模板渲染测试通过")
    except Exception as e:
        print("❌ Jinja2 测试失败:", e)

# try:
#     import jsonschema
#     from jsonschema import validate
#     schema = {"type": "object", "required": ["name"], "properties": {"name": {"type": "string"}}}
#     instance = {"name": "test"}
#     validate(instance=instance, schema=schema)
#     print("✅ jsonschema 验证测试通过")
# except Exception as e:
#     print("❌ jsonschema 测试失败:", e)

# try:
#     import numpy
#     a = numpy.array([1, 2, 3])
#     assert len(a) == 3
#     print("✅ Numpy 数组测试通过")
# except Exception as e:
#     print("❌ Numpy 测试失败:", e)

# try:
#     import pandas
#     df = pandas.DataFrame({"col": [1, 2, 3]})
#     assert len(df) == 3
#     print("✅ Pandas DataFrame 测试通过")
# except Exception as e:
#     print("❌ Pandas 测试失败:", e)

# try:
#     import loguru
#     from loguru import logger
#     logger.add("test.log")
#     logger.info("Test log message")
#     with open("test.log", "r") as f:
#         content = f.read()
#         assert "Test log message" in content
#     print("✅ Loguru 日志测试通过")
# except Exception as e:
#     print("❌ Loguru 测试失败:", e)

# print("\n🎉 所有测试完成")