Skip to content

Commit

Permalink
Migrated less_than, closes #48 and closes #49
Browse files Browse the repository at this point in the history
  • Loading branch information
bdsoha committed Dec 15, 2022
1 parent 8917467 commit 70d049f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 119 deletions.
2 changes: 1 addition & 1 deletion src/expycted/core/matchers/matcher_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def __call__(self, expected: Any = ...):
expected=expected,
)

self._expectation.qualifiers.clear()
self._expectation.qualifiers.clear()
9 changes: 3 additions & 6 deletions src/expycted/internals/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,33 +262,30 @@ def be_lesser(self) -> LessThanMatcher:

return self.be_lesser_than



@property
def be_lesser_or_equal_to(self) -> LessThanMatcher:
"""Alias for ``be_lesser_than_or_equal_to``."""

return self.be_lesser_than_or_equal_to

@property
def be_less_than_or_equal_to(self) -> LessThanMatcher:
"""Alias for ``be_lesser_than_or_equal_to``."""

return self.be_lesser_than_or_equal_to

@property
def be_less_or_equal(self) -> LessThanMatcher:
"""Alias for ``be_lesser_than_or_equal_to``."""

return self.be_lesser_than_or_equal_to

@property
def be_lesser_or_equal(self) -> LessThanMatcher:
"""Alias for ``be_lesser_than_or_equal_to``."""

return self.be_lesser_than_or_equal_to





@assertion_old
def be_greater_or_equal_to(self, actual: Any) -> None:
"""Check whether the value is greater than or equal to something
Expand Down
16 changes: 0 additions & 16 deletions test/expect_to_not_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,6 @@ def test_to_not_inherit(expected, actual, context):
expect(expected).to.inherit(actual)


@expected_actual_params(stubs.LESS_THAN, extract_ids=False)
def test_to_not_be_greater_than(expected, actual, context):
expect(expected).to_not.be_greater_than(actual)

with context.raises:
expect(expected).to.be_greater_than(actual)


@expected_actual_params(stubs.GREATER_THAN, extract_ids=False)
def test_to_not_be_lesser_than(expected, actual, context):
expect(expected).to_not.be_lesser_than(actual)

with context.raises:
expect(expected).to.be_lesser_than(actual)


@expected_params(stubs.NOT_NUMERIC, extract_ids=False)
def test_to_not_be_numeric(expected, context):
expect(expected).to_not.be_numeric()
Expand Down
44 changes: 0 additions & 44 deletions test/expect_to_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,6 @@ def test_to_be_greater_than(expected, actual, context):
expect(expected).to_not.be_greater(actual)


@expected_actual_params(stubs.LESS_THAN, extract_ids=False)
def test_to_be_lesser_than(expected, actual, context):
expect(expected).to.be_lesser_than(actual)
expect(expected).to.be_less_than(actual)
expect(expected).to.be_less(actual)
expect(expected).to.be_lesser(actual)

with context.raises:
expect(expected).to_not.be_lesser_than(actual)

with context.raises:
expect(expected).to_not.be_less_than(actual)

with context.raises:
expect(expected).to_not.be_less(actual)

with context.raises:
expect(expected).to_not.be_lesser(actual)


@expected_actual_params(stubs.GREATER_THAN_OR_EQUAL, extract_ids=False)
def test_to_be_greater_than_or_equal_to(expected, actual, context):
expect(expected).to.be_greater_than_or_equal_to(actual)
Expand All @@ -128,30 +108,6 @@ def test_to_be_greater_than_or_equal_to(expected, actual, context):
expect(expected).to_not.be_greater_or_equal(actual)


@expected_actual_params(stubs.LESS_THAN_OR_EQUAL, extract_ids=False)
def test_to_be_lesser_or_equal_to(expected, actual, context):
expect(expected).to.be_lesser_or_equal_to(actual)
expect(expected).to.be_lesser_than_or_equal_to(actual)
expect(expected).to.be_less_than_or_equal_to(actual)
expect(expected).to.be_less_or_equal(actual)
expect(expected).to.be_lesser_or_equal(actual)

with context.raises:
expect(expected).to_not.be_lesser_or_equal_to(actual)

with context.raises:
expect(expected).to_not.be_lesser_than_or_equal_to(actual)

with context.raises:
expect(expected).to_not.be_less_than_or_equal_to(actual)

with context.raises:
expect(expected).to_not.be_less_or_equal(actual)

with context.raises:
expect(expected).to_not.be_lesser_or_equal(actual)


@expected_params(stubs.NUMERIC, extract_ids=False)
def test_to_be_numeric(expected, context):
expect(expected).to.be_numeric()
Expand Down
12 changes: 0 additions & 12 deletions test/helpers/stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,13 @@ class Day(Enum):
([1, 0], [1]),
)

LESS_THAN = (
(2, 3),
(3, 3.2),
([1], [2]),
([1], [1, 0]),
)

GREATER_THAN_OR_EQUAL = (
*GREATER_THAN,
(1, 1.0),
([1], [1]),
)

LESS_THAN_OR_EQUAL = (
*LESS_THAN,
(1, 1.0),
([1], [1]),
)

NUMERIC = (
1,
"1",
Expand Down
91 changes: 51 additions & 40 deletions test/unit/matchers/test_less_than_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,54 @@ def test_via_expect(context):
expectation.to.be_less_than(1)


# @parametrize_expectation(
# [
# (stubs.SINGLETON_OBJECT(), stubs.SINGLETON_OBJECT()),
# (True, 1, "True int equivalent"),
# (False, 0, "False int equivalent"),
# (1, 1.0, "int float equivalent"),
# (True, True, "bool"),
# (1, 1, "int"),
# (1.1, 1.1, "float"),
# ("hello", "hello", "str"),
# ([True, 1.1], [True, 1.1], "list"),
# ({True, 1.1}, {1.1, True}, "set ignore order"),
# ({"a": [True, 1.1]}, {"a": [True, 1.1]}, "dict"),
# ],
# matcher=EqualMatcher,
# wrap=False,
# )
# def test_matches(expectation):
# matcher = expectation.matcher()

# assert matcher(expectation.expected) is True


# @parametrize_expectation(
# [
# (stubs.NOT_SINGLETON_OBJECT(), stubs.NOT_SINGLETON_OBJECT()),
# (True, "True", "bool (True) str equivalent"),
# (False, "False", "bool (False) str equivalent"),
# (1, "1", "int str equivalent"),
# ([True, 1.1], (True, 1.1), "list tuple equivalent"),
# (False, None, "False None equivalent"),
# (b"hello", "hello", "byte-str str equivalent"),
# ],
# matcher=EqualMatcher,
# wrap=False,
# )
# def test_not_matches(expectation):
# matcher = expectation.matcher()

# assert matcher(expectation.expected) is False
@parametrize_expectation(
[
("hello", "hello world"),
(2, 3),
(3, 3.2),
([1], [2]),
([1], [1, 0]),
],
matcher=LessThanMatcher,
wrap=False,
)
def test_matches(expectation):
matcher = expectation.matcher()

assert matcher(expectation.expected) is True


@parametrize_expectation(
[
("hello", "hello world"),
("hello", "hello"),
(2, 3),
(2, 2),
(3, 3.2),
([1], [2]),
([1], [1]),
],
matcher=LessThanMatcher,
wrap=False,
)
def test_or_equal_matches(expectation):
matcher = expectation.matcher(or_equal=True)

assert matcher(expectation.expected) is True


@parametrize_expectation(
[
("hello world", "hello"),
(3, 2),
(3.2, 3),
([2], [1]),
([1, 0], [1]),
],
matcher=LessThanMatcher,
wrap=False,
)
def test_not_matches(expectation):
matcher = expectation.matcher()

assert matcher(expectation.expected) is False

0 comments on commit 70d049f

Please sign in to comment.