hellchin-lib 0.1.2__tar.gz → 0.1.401__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hellchin_lib-0.1.401/CHANGELOG.md +12 -0
- hellchin_lib-0.1.401/MANIFEST.in +3 -0
- hellchin_lib-0.1.401/PKG-INFO +92 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/_hellchin_lib/assertion/method_assert.py +20 -6
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/_hellchin_lib/logger.py +6 -1
- hellchin_lib-0.1.401/hellchin_lib.egg-info/PKG-INFO +92 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/hellchin_lib.egg-info/SOURCES.txt +2 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/pyproject.toml +3 -3
- hellchin_lib-0.1.401/setup.py +36 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/tests/test_soft_assert/test_demo.py +1 -1
- hellchin_lib-0.1.2/PKG-INFO +0 -11
- hellchin_lib-0.1.2/hellchin_lib.egg-info/PKG-INFO +0 -11
- hellchin_lib-0.1.2/setup.py +0 -30
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/LICENSE +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/README.md +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/_hellchin_lib/__init__.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/_hellchin_lib/assertion/__init__.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/_hellchin_lib/assertion/base_soft_assert.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/_hellchin_lib/assertion/logger.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/_hellchin_lib/assertion/postman.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/hellchin_lib/__init__.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/hellchin_lib.egg-info/dependency_links.txt +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/hellchin_lib.egg-info/requires.txt +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/hellchin_lib.egg-info/top_level.txt +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/setup.cfg +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/tests/__init__.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/tests/test_soft_assert/__init__.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/tests/test_soft_assert/test_method_assert.py +0 -0
- {hellchin_lib-0.1.2 → hellchin_lib-0.1.401}/tests/test_soft_assert/test_soft_assert.py +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hellchin_lib
|
|
3
|
+
Version: 0.1.401
|
|
4
|
+
Summary: A Python library for soft assertions and flexible testing.
|
|
5
|
+
Author: hellchin
|
|
6
|
+
Author-email: your.email@example.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: pytest>=6.0.0
|
|
13
|
+
|
|
14
|
+
# hellchin-lib
|
|
15
|
+
|
|
16
|
+
## 简介
|
|
17
|
+
个人开发使用的一些工具包,主要用于自动化测试,目前主要开发断言功能,支持软硬断言。
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
20
|
+
```bash
|
|
21
|
+
pip install hellchin-lib
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 使用方法
|
|
25
|
+
|
|
26
|
+
!!!详细教程有空的时候再进行更新
|
|
27
|
+
|
|
28
|
+
建议教程如下:
|
|
29
|
+
|
|
30
|
+
示例代码:
|
|
31
|
+
```python
|
|
32
|
+
# !/usr/bin/env python
|
|
33
|
+
# -*- coding: utf-8 -*-
|
|
34
|
+
"""
|
|
35
|
+
-------------------------------------------------
|
|
36
|
+
File Name: test_demo.py
|
|
37
|
+
Description:
|
|
38
|
+
-------------------------------------------------
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
from hellchin_lib import PostManAssertMethod, MethodAssert
|
|
42
|
+
|
|
43
|
+
pm = PostManAssertMethod()
|
|
44
|
+
pm.response = {
|
|
45
|
+
"a": 1
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# raise Exception("测试")
|
|
49
|
+
pm_code_test = """
|
|
50
|
+
# pm.expect(1).to.equal(2)
|
|
51
|
+
pm.test("", lambda: pm.expect('1').to.equal(1))
|
|
52
|
+
pm.test("失败断言", lambda: pm.expect(1).to.equal(2))
|
|
53
|
+
pm.test("", lambda: pm.expect(1).to.equal(1))
|
|
54
|
+
pm.test("成功断言", lambda: pm.expect(1).to.equal(1))
|
|
55
|
+
res = pm.response.json()
|
|
56
|
+
pm.test("undefined 测试", lambda: pm.expect(res.b).to.equal(1))
|
|
57
|
+
# pm.expect(res.b).to.equal(1)
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
exec(pm_code_test, {"pm": pm})
|
|
61
|
+
|
|
62
|
+
ma_code_test = """
|
|
63
|
+
method_assert.check(1 == 1)
|
|
64
|
+
method_assert.check(1 == 2)
|
|
65
|
+
method_assert.equal(1, 1)
|
|
66
|
+
method_assert.equal(1, 2)
|
|
67
|
+
method_assert.exists(1)
|
|
68
|
+
method_assert.fail()
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
# exec(ma_code_test, {"method_assert": MethodAssert()})
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## 文档链接
|
|
77
|
+
|
|
78
|
+
更多文档请访问:None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# 更新日志
|
|
82
|
+
|
|
83
|
+
## [0.1.401] - 2024-1-3
|
|
84
|
+
### 新增
|
|
85
|
+
- pm 断言: 添加 undefined 处理
|
|
86
|
+
|
|
87
|
+
### 修复
|
|
88
|
+
- 修复了一些问题
|
|
89
|
+
- 修复日志无引用问题
|
|
90
|
+
|
|
91
|
+
### 改进
|
|
92
|
+
- 优化了一些细节代码和冗余
|
|
@@ -27,6 +27,7 @@ class AssertMsg:
|
|
|
27
27
|
self.context = context
|
|
28
28
|
|
|
29
29
|
def __call__(self, *args, **kwargs):
|
|
30
|
+
# 对象() 把对象当作函数调用,相当于执行对象.__call__()
|
|
30
31
|
return self.msg # 默认返回第一个参数作为断言信息
|
|
31
32
|
|
|
32
33
|
|
|
@@ -87,6 +88,7 @@ class BaseMethodAssert:
|
|
|
87
88
|
fail_message = fail_message.format(actual=repr(actual), expected=repr(expected))
|
|
88
89
|
assert_info_fail = f"{assert_info_success} | AssertionError: {fail_message}"
|
|
89
90
|
assert_raise_msg = AssertMsg(assert_info_fail, actual=actual, expected=expected, context=fail_message)
|
|
91
|
+
# print(f"assert_raise_msg: {assert_raise_msg()}")
|
|
90
92
|
|
|
91
93
|
# 如果实际值是未定义的,则抛出 AssertionUndefinedError
|
|
92
94
|
if self.IS_UNDEFINED:
|
|
@@ -174,9 +176,6 @@ class BaseMethodAssert:
|
|
|
174
176
|
|
|
175
177
|
return success_message
|
|
176
178
|
|
|
177
|
-
# 执行断言并记录结果
|
|
178
|
-
# self.check(actual >= expected, success_message, fail_message)
|
|
179
|
-
|
|
180
179
|
def greater_than_or_equal_v2(self, actual, expected=None, *, assert_name=None, jsonpath: str = None) -> None:
|
|
181
180
|
"""
|
|
182
181
|
判断响应值是否大于或等于预期值的逻辑。
|
|
@@ -305,7 +304,10 @@ class Expect:
|
|
|
305
304
|
"""
|
|
306
305
|
|
|
307
306
|
def __init__(self, expected_value: Any):
|
|
308
|
-
|
|
307
|
+
try:
|
|
308
|
+
self.to = BaseMethodAssert(expected_value)
|
|
309
|
+
except Exception as e:
|
|
310
|
+
print("到Expect了", e)
|
|
309
311
|
|
|
310
312
|
|
|
311
313
|
class PostManAssertMethod:
|
|
@@ -332,7 +334,8 @@ class PostManAssertMethod:
|
|
|
332
334
|
"""
|
|
333
335
|
测试方法,用于执行测试函数,并打印测试结果。
|
|
334
336
|
|
|
335
|
-
test
|
|
337
|
+
test 方法要对抛出的异常信息做特殊化处理,用来区分硬断言。
|
|
338
|
+
对所有的异常都捕获,因为它们都在test中,不需要在函数外处理
|
|
336
339
|
:param desc:
|
|
337
340
|
:param test_func:
|
|
338
341
|
:return:
|
|
@@ -396,7 +399,18 @@ class PostManAssertMethod:
|
|
|
396
399
|
|
|
397
400
|
@staticmethod
|
|
398
401
|
def expect(expected_value: Any):
|
|
399
|
-
|
|
402
|
+
"""
|
|
403
|
+
断言方法
|
|
404
|
+
需要捕获异常信息,处理后返回断言结果,这里是硬断言
|
|
405
|
+
:param expected_value:
|
|
406
|
+
:return:
|
|
407
|
+
"""
|
|
408
|
+
try:
|
|
409
|
+
return Expect(expected_value)
|
|
410
|
+
except AssertionError as e:
|
|
411
|
+
print(f"expect: ", e)
|
|
412
|
+
except Exception as e:
|
|
413
|
+
print(f"断言异常!!!检查代码", e)
|
|
400
414
|
|
|
401
415
|
|
|
402
416
|
class MethodAssert(SoftAssert):
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
from __future__ import annotations
|
|
11
11
|
|
|
12
|
+
from typing import TYPE_CHECKING
|
|
13
|
+
|
|
12
14
|
import os
|
|
13
15
|
import sys
|
|
14
16
|
|
|
@@ -17,6 +19,9 @@ from typing import Optional
|
|
|
17
19
|
|
|
18
20
|
__all__ = ["LoggerManager"]
|
|
19
21
|
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
import loguru
|
|
24
|
+
|
|
20
25
|
|
|
21
26
|
class LoggerManager:
|
|
22
27
|
"""企业级日志管理器,负责配置日志、清理过期日志、控制台和文件日志的处理"""
|
|
@@ -57,7 +62,7 @@ class LoggerManager:
|
|
|
57
62
|
self.log_size = log_size
|
|
58
63
|
self.error_level = error_level
|
|
59
64
|
|
|
60
|
-
def configure(self) ->
|
|
65
|
+
def configure(self) -> loguru.Logger:
|
|
61
66
|
"""
|
|
62
67
|
配置日志记录器,设置控制台输出和文件输出。
|
|
63
68
|
"""
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hellchin_lib
|
|
3
|
+
Version: 0.1.401
|
|
4
|
+
Summary: A Python library for soft assertions and flexible testing.
|
|
5
|
+
Author: hellchin
|
|
6
|
+
Author-email: your.email@example.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: pytest>=6.0.0
|
|
13
|
+
|
|
14
|
+
# hellchin-lib
|
|
15
|
+
|
|
16
|
+
## 简介
|
|
17
|
+
个人开发使用的一些工具包,主要用于自动化测试,目前主要开发断言功能,支持软硬断言。
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
20
|
+
```bash
|
|
21
|
+
pip install hellchin-lib
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 使用方法
|
|
25
|
+
|
|
26
|
+
!!!详细教程有空的时候再进行更新
|
|
27
|
+
|
|
28
|
+
建议教程如下:
|
|
29
|
+
|
|
30
|
+
示例代码:
|
|
31
|
+
```python
|
|
32
|
+
# !/usr/bin/env python
|
|
33
|
+
# -*- coding: utf-8 -*-
|
|
34
|
+
"""
|
|
35
|
+
-------------------------------------------------
|
|
36
|
+
File Name: test_demo.py
|
|
37
|
+
Description:
|
|
38
|
+
-------------------------------------------------
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
from hellchin_lib import PostManAssertMethod, MethodAssert
|
|
42
|
+
|
|
43
|
+
pm = PostManAssertMethod()
|
|
44
|
+
pm.response = {
|
|
45
|
+
"a": 1
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# raise Exception("测试")
|
|
49
|
+
pm_code_test = """
|
|
50
|
+
# pm.expect(1).to.equal(2)
|
|
51
|
+
pm.test("", lambda: pm.expect('1').to.equal(1))
|
|
52
|
+
pm.test("失败断言", lambda: pm.expect(1).to.equal(2))
|
|
53
|
+
pm.test("", lambda: pm.expect(1).to.equal(1))
|
|
54
|
+
pm.test("成功断言", lambda: pm.expect(1).to.equal(1))
|
|
55
|
+
res = pm.response.json()
|
|
56
|
+
pm.test("undefined 测试", lambda: pm.expect(res.b).to.equal(1))
|
|
57
|
+
# pm.expect(res.b).to.equal(1)
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
exec(pm_code_test, {"pm": pm})
|
|
61
|
+
|
|
62
|
+
ma_code_test = """
|
|
63
|
+
method_assert.check(1 == 1)
|
|
64
|
+
method_assert.check(1 == 2)
|
|
65
|
+
method_assert.equal(1, 1)
|
|
66
|
+
method_assert.equal(1, 2)
|
|
67
|
+
method_assert.exists(1)
|
|
68
|
+
method_assert.fail()
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
# exec(ma_code_test, {"method_assert": MethodAssert()})
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## 文档链接
|
|
77
|
+
|
|
78
|
+
更多文档请访问:None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# 更新日志
|
|
82
|
+
|
|
83
|
+
## [0.1.401] - 2024-1-3
|
|
84
|
+
### 新增
|
|
85
|
+
- pm 断言: 添加 undefined 处理
|
|
86
|
+
|
|
87
|
+
### 修复
|
|
88
|
+
- 修复了一些问题
|
|
89
|
+
- 修复日志无引用问题
|
|
90
|
+
|
|
91
|
+
### 改进
|
|
92
|
+
- 优化了一些细节代码和冗余
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# !/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
-------------------------------------------------
|
|
5
|
+
File Name: setup.py
|
|
6
|
+
Description: 包的元信息
|
|
7
|
+
-------------------------------------------------
|
|
8
|
+
"""
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from setuptools import setup, find_packages
|
|
12
|
+
|
|
13
|
+
# 确保路径基于 setup.py 所在目录
|
|
14
|
+
here = Path(__file__).parent
|
|
15
|
+
print(here)
|
|
16
|
+
readme = (here / "README.md").read_text(encoding="utf-8")
|
|
17
|
+
changelog = (here / "CHANGELOG.md").read_text(encoding="utf-8")
|
|
18
|
+
|
|
19
|
+
setup(
|
|
20
|
+
name="hellchin_lib", # 包名
|
|
21
|
+
version="0.1.401", # 版本号 主版本号.次版本号.修订号 重大更新.小更新.小修订
|
|
22
|
+
description="A Python library for soft assertions and flexible testing.", # 描述
|
|
23
|
+
author="hellchin", # 作者
|
|
24
|
+
author_email="your.email@example.com", # 作者邮箱
|
|
25
|
+
packages=find_packages(), # 包列表: 自动查找所有包含__init__.py文件的目录
|
|
26
|
+
install_requires=[
|
|
27
|
+
"pytest>=6.0.0", # 依赖的包
|
|
28
|
+
],
|
|
29
|
+
classifiers=[ # 分类器列表
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"License :: OSI Approved :: MIT License",
|
|
32
|
+
"Operating System :: OS Independent",
|
|
33
|
+
],
|
|
34
|
+
long_description=readme + "\n\n" + changelog,
|
|
35
|
+
long_description_content_type="text/markdown",
|
|
36
|
+
)
|
|
@@ -23,7 +23,7 @@ pm.test("", lambda: pm.expect(1).to.equal(1))
|
|
|
23
23
|
pm.test("成功断言", lambda: pm.expect(1).to.equal(1))
|
|
24
24
|
res = pm.response.json()
|
|
25
25
|
pm.test("undefined 测试", lambda: pm.expect(res.b).to.equal(1))
|
|
26
|
-
|
|
26
|
+
pm.expect(1).to.equal(2)
|
|
27
27
|
"""
|
|
28
28
|
|
|
29
29
|
exec(pm_code_test, {"pm": pm})
|
hellchin_lib-0.1.2/PKG-INFO
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: hellchin_lib
|
|
3
|
-
Version: 0.1.2
|
|
4
|
-
Summary: A Python library for soft assertions and flexible testing.
|
|
5
|
-
Author: hellchin
|
|
6
|
-
Author-email: your.email@example.com
|
|
7
|
-
Classifier: Programming Language :: Python :: 3
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
Requires-Dist: pytest>=6.0.0
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: hellchin_lib
|
|
3
|
-
Version: 0.1.2
|
|
4
|
-
Summary: A Python library for soft assertions and flexible testing.
|
|
5
|
-
Author: hellchin
|
|
6
|
-
Author-email: your.email@example.com
|
|
7
|
-
Classifier: Programming Language :: Python :: 3
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
Requires-Dist: pytest>=6.0.0
|
hellchin_lib-0.1.2/setup.py
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# !/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
-------------------------------------------------
|
|
5
|
-
File Name: setup.py
|
|
6
|
-
Description: 包的元信息
|
|
7
|
-
-------------------------------------------------
|
|
8
|
-
"""
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
from setuptools import setup, find_packages
|
|
12
|
-
|
|
13
|
-
setup(
|
|
14
|
-
name="hellchin_lib", # 包名
|
|
15
|
-
version="0.1.2", # 版本号
|
|
16
|
-
description="A Python library for soft assertions and flexible testing.", # 描述
|
|
17
|
-
author="hellchin", # 作者
|
|
18
|
-
author_email="your.email@example.com", # 作者邮箱
|
|
19
|
-
packages=find_packages(), # 包列表: 自动查找所有包含__init__.py文件的目录
|
|
20
|
-
install_requires=[
|
|
21
|
-
"pytest>=6.0.0", # 依赖的包
|
|
22
|
-
],
|
|
23
|
-
classifiers=[ # 分类器列表
|
|
24
|
-
"Programming Language :: Python :: 3",
|
|
25
|
-
"License :: OSI Approved :: MIT License",
|
|
26
|
-
"Operating System :: OS Independent",
|
|
27
|
-
],
|
|
28
|
-
# long_description=(Path("README.md").read_text() + "\n\n" + Path("CHANGELOG.md").read_text()),
|
|
29
|
-
# long_description_content_type="text/markdown",
|
|
30
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|