Exemplo n.º 1
0
def test_filebubblesort():
    input=["jettus","thanzeeh","janis","sreeraj","abhi","noothan"]
    result=bubsort(input)
    expected=["abhi","janis","jettus","noothan","sreeraj","thanzeeh"]
    assert result == expected
Exemplo n.º 2
0
def test_filebinaryseachlistinteger():
    result=bubsort(json_string['filebubblesort'][4]['input'])
    expected = json_string['filebubblesort'][4]['output']
    assert result == expected
Exemplo n.º 3
0
def test_filebubblesortstring():
    with pytest.raises(TypeError):
        result=bubsort(json_string['filebubblesort'][0]['input'])
        expected = json_string['filebubblesort'][0]['output']
        assert result == expected
Exemplo n.º 4
0
def test_filebinaryseachinteger():
    with pytest.raises(TypeError):
        result=bubsort(json_string['filebubblesort'][3]['input'])
        expected = json_string['filebubblesort'][3]['output']
        assert result == expected
Exemplo n.º 5
0
        print(e)
        sys.exit()

f1.write("jettus thanzeeh janis sreeraj abhi noothan")
f1.close()

#Reading the contents from the file
try:
    with open('xyz.txt') as f:
        content = f.read().split(' ')
except FileNotFoundError as e:
    print(e)
    sys.exit()

#Printing the contents
print("Before Sorting : ", content)

#Calling the function in the BL file
list2 = utility.bubsort(content)

print("After Sorting : ", list2)

try:
    #Writing the sorted content into the file
    with open('xyz.txt', 'w') as f3:
        for contents in list2:
            f3.write('%s\n' % contents)
except FileNotFoundError as e:
    print(e)
    sys.exit()