From e7a9a4fca6ab7aac3b4ada839d6f2641d3436cea Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Sat, 19 Oct 2019 13:52:33 +0100 Subject: [PATCH] Allow xfail to be imported directly from ward --- setup.py | 4 ++-- ward/__init__.py | 2 +- ward/expect.py | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index c7927fde..92a94de6 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ with open("README.md", "r") as fh: long_description = fh.read() -version = "0.9.0a0" +version = "0.9.1a0" setup( name="ward", version=version, - description="A Python 3 test framework.", + description="A Python 3 test framework for finding flaws faster.", long_description=long_description, long_description_content_type="text/markdown", url="http://github.com/darrenburns/ward", diff --git a/ward/__init__.py b/ward/__init__.py index 25f70cde..08f12a58 100644 --- a/ward/__init__.py +++ b/ward/__init__.py @@ -1,3 +1,3 @@ from .expect import expect, raises from .fixtures import fixture -from .test import skip +from .test import skip, xfail diff --git a/ward/expect.py b/ward/expect.py index 7d364aba..370de5ab 100644 --- a/ward/expect.py +++ b/ward/expect.py @@ -33,7 +33,7 @@ def __init__(self, message: str, history: List[Expected]): self.history = history -def record_expect_in_history(func): +def record_and_handle_outcome(func): @functools.wraps(func) def wrapped_func(self, that: Any, *args, **kwargs) -> "expect": rv = func(self, that, *args, **kwargs) @@ -56,38 +56,38 @@ def __init__(self, this: Any): self.this = this self.history: List[Expected] = [] - @record_expect_in_history + @record_and_handle_outcome def equals(self, that: Any): return self.this == that - @record_expect_in_history + @record_and_handle_outcome def is_less_than(self, that: Any): return self.this < that - @record_expect_in_history + @record_and_handle_outcome def is_greater_than(self, that: Any): return self.this > that - @record_expect_in_history + @record_and_handle_outcome def contains(self, that: Any): return that in self.this - @record_expect_in_history + @record_and_handle_outcome def has_length(self, length: int): return len(self.this) == length - @record_expect_in_history + @record_and_handle_outcome def is_instance_of(self, type: Type): return isinstance(self.this, type) - @record_expect_in_history + @record_and_handle_outcome def satisfies(self, predicate: Callable[["expect"], bool]): return predicate(self.this) - @record_expect_in_history + @record_and_handle_outcome def is_(self, that: Any): return self.this is that - @record_expect_in_history + @record_and_handle_outcome def approx(self, that: Any, epsilon: float): return math.isclose(self.this, that, abs_tol=epsilon)