Ai
3 Star 6 Fork 0

Gitee 极速下载/viztracer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/gaogaotiantian/viztracer
克隆/下载
test_invalid.py 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/gaogaotiantian/viztracer/blob/master/NOTICE.txt
from viztracer import VizTracer
from viztracer.event_base import _EventBase
from .base_tmpl import BaseTmpl
class TestInvalidArgs(BaseTmpl):
def test_invalid_args(self):
invalid_args = {
"verbose": ["hello", 0.1],
"pid_suffix": ["hello", 1, "True"],
"max_stack_depth": ["0.3", "hello", 1.5],
"include_files": ["./src"],
"exclude_files": ["./src"],
"ignore_c_function": ["hello", 1, "True"],
"log_func_retval": ["hello", 1, "True"],
"log_gc": ["hello", 1, "True"],
"log_func_args": ["hello", 1, "True"],
"min_duration": ["0.1.0", "12", "3us"],
"ignore_frozen": ["hello", 1, "True"],
"log_async": ["hello", 1, "True"],
"log_func_repr": ["hello", 1, True],
}
tracer = VizTracer(verbose=0)
for args, vals in invalid_args.items():
for val in vals:
with self.assertRaises((ValueError, TypeError)):
setattr(tracer, args, val)
class TestInvalidOperation(BaseTmpl):
def test_generate_without_data(self):
tracer = VizTracer(verbose=0)
with self.assertRaises(Exception):
tracer.generate_json()
def test_save_invalid_format(self):
tracer = VizTracer(verbose=0)
tracer.start()
_ = len([1, 2])
tracer.stop()
with self.assertRaises(Exception):
tracer.save("test.invalid")
def test_log_func_conflict(self):
with self.assertRaises(ValueError):
_ = VizTracer(log_func_repr=repr, log_func_with_objprint=True, verbose=0)
def test_add_invalid_variable(self):
tracer = VizTracer(verbose=0)
tracer.start()
with self.assertRaises(Exception):
tracer.add_variable("a", 1, event="invalid")
with self.assertRaises(Exception):
tracer.add_variable("a", "str", event="counter")
class TestUseEventBase(BaseTmpl):
def test_use_event_base(self):
event = _EventBase(None)
with self.assertRaises(NotImplementedError):
event.log()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/mirrors/viztracer.git
git@gitee.com:mirrors/viztracer.git
mirrors
viztracer
viztracer
master

搜索帮助