Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zheng Gaoshan
co-devTest
Commits
0290c6f6
Commit
0290c6f6
authored
May 19, 2025
by
qiongying.jia
Browse files
TEST
parent
546b3c0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
a.py
0 → 100644
View file @
0290c6f6
try
:
import
jinja2
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
🎉 所有测试完成"
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment