我需要帮助创建可以由 pytest 执行的测试函数。我已经创建了一个并且它通过了,但我需要测试我创建的每个函数,但不知道该怎么做。我尝试过使用断言,但我所有的测试都失败了。我看过有关理解测试的视频,但我似乎无法掌握如何使用它。我需要你的帮助。这是我到目前为止所拥有的......
import random
players = []
MAX_PLAYERS = 8
def main():
print("Are you ready to Left, Right, Center Game!")
print("----------------------------------------------------")
print("Let's play!!!")
print("----------------------------------------------------")
money = bet()
print("We are betting $"+str(money)+ " per person")
number_of_people = get_people()
number_of_people = int(number_of_people)
get_names(number_of_people)
print("All names have been entered, let's play")
run_game(players)
winners_money = money * number_of_people
print(f"You won, " + str(winners_money))
print("----------------------------------------------------")
def get_people():
while True:
try:
number_of_people = int(input("How many people are playing? (3-8) "))
if 3 <= number_of_people <= MAX_PLAYERS:
return number_of_people
except ValueError:
pass
def get_names(number_of_people):
for name in range(number_of_people):
name = input("Name: ").strip().title()
players.append({"name": name, "chips": 3})
def bet():
while True:
amount = input("How much would you like to bet? $")
if amount.isdigit():
amount = int(amount)
if amount > 0:
break
else:
print("Amount must be greater than 0.")
else:
print("Please enter a number. Number needs to be greater than 0")
return amount
def run_game(players):
chips = ["L", "R", "C", "
标签:python,pytest
From: 78776876