def not_empty_pending_list_test():
    print("Test Not Empty pending_tests List")
    print_stars()
    clear_state()
    add_test(equal_passed_test)
    assert len(pending_tests()) == 1, "Expected length: {}, Actual length: {}".format(1, len(pending_tests()))
    assert pending_tests()[0] == equal_passed_test.__name__, "Expected: {}, Actual: {}".format(pending_tests()._name_, pending_tests()[0])
    return "Pending test list contains 1 test"
def run_failed_test():
    print("Test run function with assertion errors")
    print_stars()
    clear_state()
    add_test(equal_failed_test)
    test_run_result = run()
    assert test_run_result == (1, 0, 1), "Expected : 1 test run, 0 test passed, 1 test failed, Actual: {} test run, {} test passed, {} test failed".format(*test_run_result)
    return "Result: 1 test run, 0 test passed, 1 test failed"
Beispiel #3
0
def assert_not_in_test(a, b):
    try:
        assert_not_in(a, b)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - '{}' not in '{}'".format(a, b))
    finally:
        print_stars()            
Beispiel #4
0
def assert_is_not_none_test(x):
    try:
        assert_is_not_none(x)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - '{}' is not none".format(x))
    finally:
        print_stars()  
Beispiel #5
0
def assert_is_not_test(a, b):
    try:
        assert_is_not(a, b)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - '{}' is not identical to '{}'".format(id(a), id(b)))
    finally:
        print_stars()     
Beispiel #6
0
def assert_equal_test(a, b):
    try:
        assert_equal(a, b)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - '{}' is equal to '{}'".format(a, b))
    finally:
        print_stars()
Beispiel #7
0
def assert_in_test(a, b):
    try:
        assert_in(a, b)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - '{}' in '{}'".format(a, b))
    finally:
        print_stars()
Beispiel #8
0
def assert_is_not_none_test(x):
    try:
        assert_is_not_none(x)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - '{}' is not none".format(x))
    finally:
        print_stars()
Beispiel #9
0
def assert_is_not_test(a, b):
    try:
        assert_is_not(a, b)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - '{}' is not identical to '{}'".format(id(a), id(b)))
    finally:
        print_stars()
Beispiel #10
0
def assert_not_equal_test(a, b):
    try:
        assert_not_equal(a, b)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - '{}' is not equal to '{}'".format(a, b))
    finally:
        print_stars()
def test_runner_test(fn):
    try:
        passed_test_message = fn
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - {0}".format(passed_test_message))
    finally:
        print_stars()
Beispiel #12
0
def assertion_test(f, passed_test_message, *args):
    try:
        f(*args)
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print(passed_test_message.format(*args))
    finally:
        print_stars()
Beispiel #13
0
def test_runner_test(fn):
    try:
        passed_test_message = fn
    except AssertionError as e:
        print("Failed - Exception caught: %r" % e.message)
    else:
        print("Passed - {0}".format(passed_test_message))
    finally:
        print_stars()
def list_failed_run_test():
    print("Test passed_tests and failed_tests functions with assertion errors")
    print_stars()
    clear_state()
    add_test(equal_failed_test)
    run()
    assert len(passed_tests()) == 0, "Expected length: {}, Actual length: {}".format(0, len(passed_tests()))
    assert len(failed_tests()) == 1, "Expected length: {}, Actual length: {}".format(1, len(failed_tests()))
    assert failed_tests()[0] == equal_failed_test.__name__, "Expected: {}, Actual: {}".format(failed_tests()._name_, failed_tests()[0])
    return "Result: 1 test passed, 0 test failed"
Beispiel #15
0
def run_failed_test():
    print("Test run function with assertion errors")
    print_stars()
    clear_state()
    add_test(equal_failed_test)
    test_run_result = run()
    assert test_run_result == (
        1, 0, 1
    ), "Expected : 1 test run, 0 test passed, 1 test failed, Actual: {} test run, {} test passed, {} test failed".format(
        *test_run_result)
    return "Result: 1 test run, 0 test passed, 1 test failed"
Beispiel #16
0
def not_empty_pending_list_test():
    print("Test Not Empty pending_tests List")
    print_stars()
    clear_state()
    add_test(equal_passed_test)
    assert len(
        pending_tests()) == 1, "Expected length: {}, Actual length: {}".format(
            1, len(pending_tests()))
    assert pending_tests(
    )[0] == equal_passed_test.__name__, "Expected: {}, Actual: {}".format(
        pending_tests()._name_,
        pending_tests()[0])
    return "Pending test list contains 1 test"
Beispiel #17
0
def list_failed_run_test():
    print("Test passed_tests and failed_tests functions with assertion errors")
    print_stars()
    clear_state()
    add_test(equal_failed_test)
    run()
    assert len(
        passed_tests()) == 0, "Expected length: {}, Actual length: {}".format(
            0, len(passed_tests()))
    assert len(
        failed_tests()) == 1, "Expected length: {}, Actual length: {}".format(
            1, len(failed_tests()))
    assert failed_tests(
    )[0] == equal_failed_test.__name__, "Expected: {}, Actual: {}".format(
        failed_tests()._name_,
        failed_tests()[0])
    return "Result: 1 test passed, 0 test failed"
Beispiel #18
0
def print_division_result(a, b):
    print_stars()
    print("Trying to divide '{}' by '{}'".format(a, b))
    print("Result: '{}'".format(divide(a, b)))
def empty_list_test():
    print("Test Empty pending_tests List")
    print_stars()
    clear_state()
    assert len(pending_tests()) == 0, "Pending test list is not empty"
    return "Pending test list is empty"
Beispiel #20
0
def equal_passed_test():
    print("Test lists equality, result - passed")
    print_stars()
    a = [1, 4]
    b = [1, 4]
    assert_equal(a, b)
Beispiel #21
0
def is_none_failed_test():
    print("Test if variable is none, result - failed")
    print_stars()
    x = None
    assert_is_none(x)
Beispiel #22
0
def equal_passed_test():
    print("Test lists equality, result - passed")
    print_stars()
    a = [1, 4]
    b = [1, 4]
    assert_equal(a, b)
Beispiel #23
0
# -*- coding: utf-8 -*-
from examples_2.utils import print_stars

single_line_byte_string = "single line byte string"
print(single_line_byte_string)
print_stars()

multi_line_byte_string = """Multi
Line
Byte
String"""
print(multi_line_byte_string)
print_stars()

single_line_unicode_string = u"single line unicode string \u263a"
print(single_line_unicode_string)
print_stars()

# search for occurences
print("x in abc? {}".format("x" in "abc"))
print("x in xyz? {}".format("x" in "xyz"))
print_stars()

# string length
print('len("12345"): {}'.format(len("12345")))
print_stars()

# c-style format: http://docs.python.org/2/library/stdtypes.html#string-formatting
print("c-style format: %d" % 1.0)
print_stars()
Beispiel #24
0
def print_division_result(a, b):
    print_stars()
    print("Trying to divide '{}' by '{}'".format(a, b))
    print("Result: '{}'".format(divide(a,b)))
Beispiel #25
0
def empty_list_test():
    print("Test Empty pending_tests List")
    print_stars()
    clear_state()
    assert len(pending_tests()) == 0, "Pending test list is not empty"
    return "Pending test list is empty"
Beispiel #26
0
from examples_2.utils import print_stars

empty_list = []
non_empty_list = [1, 'string', 3.0]

# Lists are mutable
print("Before append(4):   %r" % non_empty_list)
non_empty_list.append(4)
print("After append(4):    %r" % non_empty_list)
non_empty_list.insert(0, 0)
print("After insert(0, 0): %r" % non_empty_list)
non_empty_list.pop(1)
print("After pop(1):       %r" % non_empty_list)
non_empty_list[0] = "new 0"
print("After set element:  %r" % non_empty_list)
print_stars()

# Lists are indexed (starting from 0)
print("non_empty_list[1]:        %r" % non_empty_list[1])
print("non_empty_list[1:-1]:     %r" % non_empty_list[1:-1])
print("Slice and List are not same objects: %r" %
      (non_empty_list is not non_empty_list[:]))
print_stars()

# Lists algebra
print("[1, 2] + [3, 4] = %r" % ([1, 2] + [3, 4]))
print("[1] * 4 =         %r" % ([1] * 4))
print_stars()

# List comprehensions
list_0 = [el for el in [1, 2, 3, 4]]
Beispiel #27
0
def is_none_failed_test():
    print("Test if variable is none, result - failed")
    print_stars()
    x = None
    assert_is_none(x)