Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
))
("this(' aa \n ').should.look_like('aa')")
assert this(' \n aa \n ').should.look_like('AA')
assert this(' \n bb \n ').should_not.look_like('aa')
def opposite():
assert this('\n aa \n').should.look_like('bb')
def opposite_not():
assert this('\n aa \n').should_not.look_like('aa')
expect(opposite).when.called.to.throw(AssertionError)
expect(opposite).when.called.to.throw(compat_repr(r"'\n aa \n' does not look like 'bb'"))
expect(opposite_not).when.called.to.throw(AssertionError)
expect(opposite_not).when.called.to.throw(compat_repr(r"'\n aa \n' should not look like 'aa' but does"))
def test_deep_equals_failing_complex_vs_basic():
"that(X) deep_equals(Y) fails with complex vc basic 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 dict and Y is a %s instead" % text_type_name,
))
jay = Person()
assert this(jay).should.have.property("name").being.equal("John Doe")
assert this(jay).should.have.property("name").not_being.equal("Foo")
def opposite():
assert this(jay).should.have.property("name").not_being.equal(
"John Doe")
def opposite_not():
assert this(jay).should.have.property("name").being.equal(
"Foo")
expect(opposite).when.called.to.throw(AssertionError)
expect(opposite).when.called.to.throw(compat_repr(
"'John Doe' should differ from 'John Doe', but is the same thing"))
expect(opposite_not).when.called.to.throw(AssertionError)
expect(opposite_not).when.called.to.throw(compat_repr(
"X is 'John Doe' whereas Y is 'Foo'"))
def test_deep_equals_list_level2_fail_by_length_x_gt_y():
"that(list) deep_equals(list) failing by length (len(X) > len(Y))"
something = {'iterable': ['one', 'yeah', 'awesome!']}
def assertions():
assert that(something).deep_equals({'iterable': ['one', 'yeah']})
assert that(assertions).raises(
AssertionError, compat_repr(
"given\n" \
"X = {'iterable': ['one', 'yeah', 'awesome!']}\n" \
def test_deep_equals_list_level1_fail_by_length_y_gt_x():
"that(list) deep_equals(list) failing by length (len(Y) > len(X))"
something = ['one', 'yeah']
def assertions():
assert that(something).deep_equals(['one', 'yeah', 'damn'])
assert that(assertions).raises(
AssertionError, compat_repr(
"given\n"
"X = ['one', 'yeah']\n"
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'))
)
something = {
'my::all_users': [
{'name': 'John', 'age': 33},
],
}
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, 'name': 'John'}]}\n" \
def test_look_like():
("this(' aa \n ').should.look_like('aa')")
assert this(' \n aa \n ').should.look_like('AA')
assert this(' \n bb \n ').should_not.look_like('aa')
def opposite():
assert this('\n aa \n').should.look_like('bb')
def opposite_not():
assert this('\n aa \n').should_not.look_like('aa')
expect(opposite).when.called.to.throw(AssertionError)
expect(opposite).when.called.to.throw(compat_repr(r"'\n aa \n' does not look like 'bb'"))
expect(opposite_not).when.called.to.throw(AssertionError)
expect(opposite_not).when.called.to.throw(compat_repr(r"'\n aa \n' should not look like 'aa' but does"))
def test_deep_equals_tuple_level1_fail_by_length_y_gt_x():
"that(tuple) deep_equals(tuple) failing by length (len(Y) > len(X))"
something = ('one', 'yeah')
def assertions():
assert that(something).deep_equals(('one', 'yeah', 'damn'))
assert that(assertions).raises(
AssertionError, compat_repr(
"given\n" \
"X = ('one', 'yeah')\n" \