Exemplo n.º 1
0
def test_doubleit_type():
    """This functions test whether the function fails right"""
    with pytest.raises(TypeError):
        myprogram.doubleit("hello")
Exemplo n.º 2
0
def test_doubleit():
    """This functions checks if the functions works fine"""
    assert myprogram.doubleit(10) == 20
import sys
def doubleit(x):
    if not isinstance(x, (int,float))
    var = x*2
    return var

if __name__ == '__main__':
    input_val = sys.argv[1]
    double_val = doubleit(input_val)

    print 'the value of {0} is {1}'.format(input_val, double_val)


######################################
# in a file called test_myprogram.py #
######################################
import myprogram
import pytest

def test_doubleit():
    assert myprogram.doubleit(10) == 20


def test_doubleit_tyoe()
    with pytest.raises(TypeError):
        myprogram.doubleit('hello')




def test_doubleit():
    assert myprogram.doubleit(10) == 20
Exemplo n.º 5
0
def test_doubleit_type():
    with pytest.raises(TypeError):  # asserting a raised error, basically
        myprogram.doubleit('hello')
    print("Looking for an int, not a string!")
Exemplo n.º 6
0
def test_doubleit_type():
    with pytest.raises(TypeError):
        myprogram.doubleit('String')
Exemplo n.º 7
0
def test_doubleit():
	# This is the assert statement and it's a core we're doing here
	# We know that our doubleit function should give us number
	# multiplied by two. So assert statement should check if it's true
	assert myprogram.doubleit(10) == 20
Exemplo n.º 8
0
 def test_doubleit(self):
     assert myprogram.doubleit(10) == 20
Exemplo n.º 9
0
def test_doubleit_type():
    with pytest.raises(TypeError):
        myprogram.doubleit('5adsfsdf')
Exemplo n.º 10
0
def test_doubleit_type():
	with pytest.raises(TypeError):
		myprogram.doubleit('hello')
Exemplo n.º 11
0
 def test_doubleit_type(self):
     """ test doubleit() type safety """
     with pytest.raises(TypeError):
         myprogram.doubleit('hello')
Exemplo n.º 12
0
 def test_doubleit_value(self):
     """ test doubleit() basic behavior """
     assert myprogram.doubleit(10) == 20
def test_doublelit():
    assert myprogram.doubleit(10) == 20
Exemplo n.º 14
0
 def test_doubleit_value(self):
     assert myprogram.doubleit(10) == 20
Exemplo n.º 15
0
 def test_doubleit(self):
     assert (myprogram.doubleit(10) == 20)
Exemplo n.º 16
0
 def test_doubleit_type(self):
     with pytest.raises(TypeError):
         myprogram.doubleit("Hello")
Exemplo n.º 17
0
 def test_doubleit_type(self):
     with pytest.raises(TypeError):  # function rises exception
         myprogram.doubleit("hello")
Exemplo n.º 18
0
 def test_doubleit_type(self):
     with pytest.raises(TypeError):
         myprogram.doubleit('hi')
Exemplo n.º 19
0
def test_doubleit():
    assert myprogram.doubleit(10) == 20
    a = myprogram.doubleit(10)
    print("Double it = " + str(a))