Esempio n. 1
0
def test_doubleit_type():
    """This functions test whether the function fails right"""
    with pytest.raises(TypeError):
        myprogram.doubleit("hello")
Esempio 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
Esempio 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!")
Esempio n. 6
0
def test_doubleit_type():
    with pytest.raises(TypeError):
        myprogram.doubleit('String')
Esempio 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
Esempio n. 8
0
 def test_doubleit(self):
     assert myprogram.doubleit(10) == 20
def test_doubleit_type():
    with pytest.raises(TypeError):
        myprogram.doubleit('5adsfsdf')
Esempio n. 10
0
def test_doubleit_type():
	with pytest.raises(TypeError):
		myprogram.doubleit('hello')
Esempio n. 11
0
 def test_doubleit_type(self):
     """ test doubleit() type safety """
     with pytest.raises(TypeError):
         myprogram.doubleit('hello')
Esempio 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
Esempio n. 14
0
 def test_doubleit_value(self):
     assert myprogram.doubleit(10) == 20
Esempio n. 15
0
 def test_doubleit(self):
     assert (myprogram.doubleit(10) == 20)
Esempio n. 16
0
 def test_doubleit_type(self):
     with pytest.raises(TypeError):
         myprogram.doubleit("Hello")
Esempio n. 17
0
 def test_doubleit_type(self):
     with pytest.raises(TypeError):  # function rises exception
         myprogram.doubleit("hello")
Esempio n. 18
0
 def test_doubleit_type(self):
     with pytest.raises(TypeError):
         myprogram.doubleit('hi')
Esempio n. 19
0
def test_doubleit():
    assert myprogram.doubleit(10) == 20
    a = myprogram.doubleit(10)
    print("Double it = " + str(a))