mwilliamson / python-precisely

Matcher library for Python
BSD 2-Clause "Simplified" License
238 stars 11 forks source link

Unexpected FAILED #6

Closed danodonovan closed 6 years ago

danodonovan commented 6 years ago

When testing a dictionary inside a list, greater_than_or_equal_to fails;

def test_mapping_inside_list_with_integer():
    data = [{
        "integer": 1,
    }]

    assert_that(data, contains_exactly(is_mapping({
        "integer": greater_than_or_equal_to(1),
    })))

results in

AssertionError:
Expected: iterable containing 1 element:
  * mapping with items:
    * 'integer': <precisely.comparison_matchers.ComparisonMatcher object at 0x1115f5b38>
but: was missing element:
  * mapping with items:
    * 'integer': <precisely.comparison_matchers.ComparisonMatcher object at 0x1115f5b38>
These elements were in the iterable, but did not match:
  * {'integer': 1}: value for key 'integer' mismatched:
    * was 1

NB replacing greater_than_or_equal_to with is_instance or another matcher succeeds.

mwilliamson commented 6 years ago

What version are you using? It sounds like the issue resolved by https://github.com/mwilliamson/python-precisely/commit/bbceb4de01bfbc62d1f9a8bf191cb03cfe2dbb00

On Tue, 24 Apr 2018 08:19:22 -0700 danodonovan notifications@github.com wrote:

When testing a dictionary inside a list, greater_than_or_equal_to fails;

def test_mapping_inside_list_with_integer():
    data = [{
        "integer": 1,
    }]

    assert_that(data, contains_exactly(is_mapping({
        "integer": greater_than_or_equal_to(1),
    })))

results in

AssertionError:
Expected: iterable containing 1 element:
  * mapping with items:
    * 'integer': <precisely.comparison_matchers.ComparisonMatcher
object at 0x1115f5b38> but: was missing element:
  * mapping with items:
    * 'integer': <precisely.comparison_matchers.ComparisonMatcher
object at 0x1115f5b38> These elements were in the iterable, but did
not match:
  * {'integer': 1}: value for key 'integer' mismatched:
    * was 1

NB replacing greater_than_or_equal_to with is_instance or another matcher succeeds.

danodonovan commented 6 years ago

Yep, my local checkout was out of date. Thanks.