asserts
Advanced tools
+11
-2
@@ -883,2 +883,3 @@ """ | ||
| self._exc_type = exception | ||
| self._exc_val = None | ||
| self._exception_name = getattr(exception, "__name__", str(exception)) | ||
@@ -888,8 +889,9 @@ self._tests = [] | ||
| def __enter__(self): | ||
| pass | ||
| return self | ||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| if not exc_type: | ||
| if not exc_type or not exc_val: | ||
| msg = "{} not raised".format(self._exception_name) | ||
| fail(self.format_message(msg)) | ||
| self._exc_val = exc_val | ||
| if not issubclass(exc_type, self.exception): | ||
@@ -918,3 +920,9 @@ return False | ||
| @property | ||
| def exc_val(self): | ||
| if self._exc_val is None: | ||
| raise RuntimeError("must be called after leaving the context") | ||
| return self._exc_val | ||
| class AssertRaisesRegexContext(AssertRaisesContext): | ||
@@ -1172,2 +1180,3 @@ | ||
| self._warnings = self._warning_context.__enter__() | ||
| return self | ||
@@ -1174,0 +1183,0 @@ def __exit__(self, exc_type, exc_val, exc_tb): |
+11
-6
@@ -22,2 +22,3 @@ import datetime | ||
| _E = TypeVar("_E", bound=BaseException) | ||
| _S = TypeVar("_S") | ||
@@ -28,8 +29,10 @@ class AssertRaisesContext(Generic[_E]): | ||
| def __init__(self, exception: Type[_E], msg_fmt: Text = ...) -> None: ... | ||
| def __enter__(self) -> AssertRaisesContext: ... | ||
| def __enter__(self: _S) -> _S: ... | ||
| def __exit__( | ||
| self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] | ||
| ) -> Optional[bool]: ... | ||
| ) -> bool: ... | ||
| def format_message(self, default_msg: Text) -> Text: ... | ||
| def add_test(self, cb: Callable[[_E], None]) -> None: ... | ||
| def add_test(self, cb: Callable[[_E], Any]) -> None: ... | ||
| @property | ||
| def exc_val(self) -> _E: ... | ||
@@ -46,6 +49,8 @@ class AssertRaisesErrnoContext(AssertRaisesContext[_E]): | ||
| def __init__(self, warning_class: Type[Warning], msg_fmt: Text = ...) -> None: ... | ||
| def __enter__(self) -> None: ... | ||
| def __exit__(self, exc_type: Type[BaseException], exc_val: BaseException, exc_tb: Any) -> None: ... | ||
| def __enter__(self: _S) -> _S: ... | ||
| def __exit__( | ||
| self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType], | ||
| ) -> None: ... | ||
| def format_message(self) -> Text: ... | ||
| def add_test(self, cb: Callable[[Warning], None]) -> None: ... | ||
| def add_test(self, cb: Callable[[Warning], bool]) -> None: ... | ||
@@ -52,0 +57,0 @@ class AssertWarnsRegexContext(AssertWarnsContext): |
+3
-3
| Metadata-Version: 2.1 | ||
| Name: asserts | ||
| Version: 0.9.1 | ||
| Version: 0.10.0 | ||
| Summary: Stand-alone Assertions | ||
@@ -16,9 +16,9 @@ Home-page: https://github.com/srittau/python-asserts | ||
| Classifier: Programming Language :: Python :: 3 | ||
| Classifier: Programming Language :: Python :: 3.4 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Topic :: Software Development :: Quality Assurance | ||
| Classifier: Topic :: Software Development :: Testing | ||
| Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* | ||
| Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* | ||
@@ -25,0 +25,0 @@ Python Asserts |
+7
-7
@@ -1,8 +0,8 @@ | ||
| asserts/__init__.py,sha256=tmy7BRycylMSH1HW80bY8tWfLebDpxc1RWQGh-nfx_g,46625 | ||
| asserts/__init__.pyi,sha256=__RUhSRXwr0X2L4AGimLUZxDXvuvUKCyLlKP6XgUDb8,4959 | ||
| asserts/__init__.py,sha256=fIwsERVXPWdK3h8k95Kc3WgiOJt3Ho98821nG2WKdks,46904 | ||
| asserts/__init__.pyi,sha256=1qMZ57DJ-sWbsLESS57FY9L5r-C7zhZ4zME3emgPwuY,5058 | ||
| asserts/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
| asserts-0.9.1.dist-info/LICENSE,sha256=lnpupgjKL_g2d4MvBlkaarYrbSpTVVbDoB8QXZffS-k,1083 | ||
| asserts-0.9.1.dist-info/METADATA,sha256=K8jSj2-gbK5xCWTcWBgOPJi24o59UCItyyYu3RYWxtU,2601 | ||
| asserts-0.9.1.dist-info/WHEEL,sha256=HX-v9-noUkyUoxyZ1PMSuS7auUxDAR4VBdoYLqD0xws,110 | ||
| asserts-0.9.1.dist-info/top_level.txt,sha256=spq0DBKMgLrtKtxTqWdr2Djd6YUkm-GSkNuHFObf9oo,8 | ||
| asserts-0.9.1.dist-info/RECORD,, | ||
| asserts-0.10.0.dist-info/LICENSE,sha256=lnpupgjKL_g2d4MvBlkaarYrbSpTVVbDoB8QXZffS-k,1083 | ||
| asserts-0.10.0.dist-info/METADATA,sha256=pTZr1mp0K4To23lDXoXTkP34skadWmhi6BQ4uOlBWpA,2611 | ||
| asserts-0.10.0.dist-info/WHEEL,sha256=8zNYZbwQSXoB9IfXOjPfeNwvAsALAjffgk27FqvCWbo,110 | ||
| asserts-0.10.0.dist-info/top_level.txt,sha256=spq0DBKMgLrtKtxTqWdr2Djd6YUkm-GSkNuHFObf9oo,8 | ||
| asserts-0.10.0.dist-info/RECORD,, |
+1
-1
| Wheel-Version: 1.0 | ||
| Generator: bdist_wheel (0.33.1) | ||
| Generator: bdist_wheel (0.33.6) | ||
| Root-Is-Purelib: true | ||
@@ -4,0 +4,0 @@ Tag: py2-none-any |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.