Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Allow xfail to be imported directly from ward
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren Burns committed Oct 19, 2019
1 parent d9d30fe commit e7a9a4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ward/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .expect import expect, raises
from .fixtures import fixture
from .test import skip
from .test import skip, xfail
20 changes: 10 additions & 10 deletions ward/expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

0 comments on commit e7a9a4f

Please sign in to comment.