Esempio n. 1
0
def test_is_not_equal_list_failure():
    try:
        AX(['a中文','b']).is_not_equal_to(['a中文','b'])
        assert False, ('should have raised error')
    except AssertionError as ex:
        ex_fmt = str_fmt(ex)
        AX(str_fmt(ex)).ends_with(b"Expected <[u'a\u4e2d\u6587', u'b']> to be not equal to <[u'a\u4e2d\u6587', u'b']>, but was.")
Esempio n. 2
0
def test_is_equal():
    AX('foo').is_equal_to('foo')
    AX(123).is_equal_to(123)
    AX(0.11).is_equal_to(0.11)
    AX(['a中文','b']).is_equal_to(['a中文','b'])
    AX((1,2,3)).is_equal_to((1,2,3))
    AX(1 == 1).is_equal_to(True)
    AX(1 == 2).is_equal_to(False)
    AX(set(['a中文','b'])).is_equal_to(set(['b','a中文']))
    AX({ 'a':1,'b':2 }).is_equal_to({ 'b':2,'a':1 })
Esempio n. 3
0
def test_is_true():
    AX(True).is_true()
    AX(1 == 1).is_true()
    AX(1).is_true()
    AX('a中文').is_true()
    AX([1]).is_true()
    AX(['a中文']).is_true()
    AX({'a中文': 1}).is_true()
Esempio n. 4
0
def test_is_false():
    AX(False).is_false()
    AX(1 == 2).is_false()
    AX(0).is_false()
    AX([]).is_false()
    AX({}).is_false()
    AX(()).is_false()
Esempio n. 5
0
def test_extract_property():
    AX(people).extracting('name').contains('Fred Smith','Joe Coder')
Esempio n. 6
0
def test_extract_attribute():
    AX(people).extracting('first_name').is_equal_to(['Fred','Joe'])
    AX(people).extracting('first_name').contains('Fred','Joe')
Esempio n. 7
0
def test_is_instance_of_class_failure():
    try:
        AX(fred.__class__).is_instance_of(Person)
        assert False, ('should have raised error')
    except AssertionError as ex:
        AX(str(ex)).contains('to be instance of class <Person>, but was not')
Esempio n. 8
0
def test_is_instance_of_class():
    AX(fred.__class__).is_instance_of(Person.__class__)
Esempio n. 9
0
def test_is_instance_of():
    AX(fred).is_instance_of(Person)
    AX(fred).is_instance_of(object)

    AX(joe).is_instance_of(Developer)
    AX(joe).is_instance_of(Person)
    AX(joe).is_instance_of(object)

    AX(car).is_instance_of(Car)
    AX(car).is_instance_of(AbstractAutomobile)
    AX(car).is_instance_of(object)

    AX(truck).is_instance_of(Truck)
    AX(truck).is_instance_of(AbstractAutomobile)
    AX(truck).is_instance_of(object)
Esempio n. 10
0
def test_is_not_equal():
    AX('foo').is_not_equal_to('bar')
    AX(123).is_not_equal_to(234)
    AX(0.11).is_not_equal_to(0.12)
    AX(['a中文','b']).is_not_equal_to(['a中文','x'])
    AX(['a中文','b']).is_not_equal_to(['a'])
    AX(['a中文','b']).is_not_equal_to(['a中文','b','c'])
    AX((1,2,3)).is_not_equal_to((1,2))
    AX(1 == 1).is_not_equal_to(False)
    AX(1 == 2).is_not_equal_to(True)
    AX(set(['a中文','b'])).is_not_equal_to(set(['a']))
    AX({ 'a':1,'b':2 }).is_not_equal_to({ 'a':1,'b':3 })
    AX({ 'a':1,'b':2 }).is_not_equal_to({ 'a':1,'c':2 })
Esempio n. 11
0
def test_is_type_of():
    AX(fred).is_type_of(Person)
    AX(joe).is_type_of(Developer)
    AX(car).is_type_of(Car)
    AX(truck).is_type_of(Truck)
Esempio n. 12
0
def test_extract_zero_arg_method():
    AX(people).extracting('say_hello').contains('Hello, Fred!', 'Joe writes code.')
Esempio n. 13
0
def test_extract_multiple():
    AX(people).extracting('first_name', 'name').contains(('Fred','Fred Smith'), ('Joe','Joe Coder'))
Esempio n. 14
0
def test_is_not_equal_int_failure():
    try:
        AX(123).is_not_equal_to(123)
        assert False, ('should have raised error')
    except AssertionError as ex:
        AX(str_fmt(ex)).ends_with('Expected <123> to be not equal to <123>, but was.')
Esempio n. 15
0
def test_is_false_failure():
    try:
        AX(True).is_false()
        assert False, 'should have raised error'
    except AssertionError as ex:
        AX(str(ex)).ends_with('Expected <False>, but was not.')
Esempio n. 16
0
def test_is_type_of_class():
    AX(fred.__class__).is_type_of(Person.__class__)
Esempio n. 17
0
def test_is_equal_failure():
    try:
        AX('foo').is_equal_to('bar')
        assert False, ('should have raised error')
    except AssertionError as ex:
        AX(str_fmt(ex)).ends_with('Expected <foo> to be equal to <bar>, but was not.')