Basic use python + pytest (asserted)

The basic usage #pytest 
# installation: the install pytest PIP
# run in the current directory: input pytest

# 1. asserted

# Function: for calculating the sum of a and b and

DEF the Add (a, b):
return a + b

# function: primes for determining

DEF is_prime (n-):
IF n-<. 1:
return False
for I in Range (2, n-):
IF I n-% == 0:
return False
return True

# test for equality
DEF test_add_1 ():
Assert the Add (3,4-). 7 ==

# test unequal
DEF test_add_2 ():
! Assert the Add (17,22) = 50

# test greater than or equal
DEF test_add_3 ():
Assert the Add (17,22) <= 50

# test less than or equal
DEF test_add_4 ():
Assert the Add (17,22)> = 38 is

# test comprising
def test_in ():
A = 'the Hello'
B = 'of He'
Assert B in A

# test does not contain
DEF test_not_in ():
A = 'the Hello'
B = 'Hi'
Assert B Not in A

# determines whether the True
DEF test_true_1 ():
Assert is_prime (13)

# determines whether the True
DEF test_true_2 ():
Assert is_prime (. 7) iS True

# determines whether or not True
DEF test_true_3 ():
Assert is_prime (. 4)

# determines whether or not True
DEF test_true_4 ():
Assert is_prime ( 6) iS not True

# determine whether the False
DEF test_false_1 ():
the Assert is_prime (8) iS False

Guess you like

Origin www.cnblogs.com/Teachertao/p/11902078.html