How to use the sure.deprecated.that function in sure

To help you get started, we’ve selected a few sure examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def i_can_use_actions(context):
        assert that(context.action1()).equals(context)
        assert that(context.action2()).equals(context)
        return True
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def test_that_contains_tuple():
    "that(('foobar', '123')).contains('foobar')"

    data = ('foobar', '123')
    assert 'foobar' in data
    assert that(data).contains('foobar')
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def test_deep_equals_fallsback_to_generic_comparator_failing():
    "that() deep_equals(dict) with generic comparator failing"
    from datetime import datetime
    now = datetime(2012, 3, 5)
    tomorrow = datetime(2012, 3, 6)
    something = {
        'date': now,
    }

    def assertions():
        assert that(something).deep_equals({
            'date': tomorrow,
        })

    assert that(assertions).raises(
        AssertionError, compat_repr(
        "given\n" \
        "X = {'date': datetime.datetime(2012, 3, 5, 0, 0)}\n" \
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
"that() deep_equals(dict) failing on level 3 when missing a key"

    something = {
        'my::all_users': [
            {'name': 'John', 'age': 33},
        ],
    }

    def assertions():
        assert that(something).deep_equals({
            'my::all_users': [
                {'name': 'John', 'age': 30, 'foo': 'bar'},
            ],
        })

    assert that(assertions).raises(
        AssertionError, compat_repr(
            "given\n"
            "X = {{'my::all_users': [{{'age': 33, 'name': 'John'}}]}}\n"
            "    and\n"
            "Y = {{'my::all_users': [{{'age': 30, 'foo': 'bar', 'name': 'John'}}]}}\n"
            "X['my::all_users'][0] does not have the key \"{0}\" whereas Y['my::all_users'][0] has it"
        ).format(safe_repr('foo'))
    )
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def depends_on_fails(the):
        assert that(the.lonely_action).raises(AssertionError, error)
        return True
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def test_that_contains_set():
    "that(set(['foobar', '123']).contains('foobar')"

    data = set(['foobar', '123'])
    assert 'foobar' in data
    assert that(data).contains('foobar')
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
"that() deep_equals(dict) failing on level 3 when has an extra key"

    something = {
        'my::all_users': [
            {'name': 'John', 'age': 33, 'foo': 'bar'},
        ],
    }

    def assertions():
        assert that(something).deep_equals({
            'my::all_users': [
                {'name': 'John', 'age': 30},
            ],
        })

    assert that(assertions).raises(
        AssertionError, compat_repr(
        "given\n"
        "X = {{'my::all_users': [{{'age': 33, 'foo': 'bar', 'name': 'John'}}]}}\n"
        "    and\n"
        "Y = {{'my::all_users': [{{'age': 30, 'name': 'John'}}]}}\n"
        "X['my::all_users'][0] has the key \"{0}\" whereas Y['my::all_users'][0] does not"
    ).format(safe_repr('foo')))
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def test_deep_equals_failing_basic_vs_complex():
    "that(X) deep_equals(Y) fails with basic vc complex type"

    def assertions():
        assert that('two yeah').deep_equals({
            'two': 'yeah',
        })

    assert that(assertions).raises(
        AssertionError, compat_repr(
        "given\n" \
        "X = 'two yeah'\n"
        "    and\n" \
        "Y = {'two': 'yeah'}\n" \
        "X is a %s and Y is a dict instead" % text_type_name,
    ))
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def test_that_contains_dictionary_keys():
    "that(dict(name='foobar')).contains('name')"

    data = dict(name='foobar')
    assert 'name' in data
    assert 'name' in data.keys()
    assert that(data).contains('name')
github gabrielfalcao / sure / tests / test_old_api.py View on Github external
def assertions():
        assert that(something).deep_equals({
            'my::all_users': [
            {'name': 'John', 'age': 33, 'bar': 'foo'},
            ],