class Test(unittest.TestCase): def setUp(self): self.card_1 = Card("Geography", "What is the capital of Alaska?", "Juneau") self.card_2 = Card( "STEM", "The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars") self.card_3 = Card( "STEM", "Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west") self.deck = Deck([self.card_1, self.card_2, self.card_3]) def test_it_has_attributes(self): self.assertEqual(self.deck.cards, [self.card_1, self.card_2, self.card_3]) def test_add_card(self): self.assertEqual(self.deck.cards, [self.card_1, self.card_2, self.card_3]) self.card4 = Card("Geography", "What is it?", "I don't know!") expected = [self.card_1, self.card_2, self.card_3, self.card4] self.deck.add_card(self.card4) self.assertEqual(self.deck.cards, expected) def test_it_can_get_all_categories(self): expected = ['STEM', 'Geography'] self.assertEqual(self.deck.all_categories(), expected)
from lib.turn import Turn from lib.deck import Deck from lib.round import Round card_1 = Card("In what state is Greendale Community College?", "colorado", 'Community Trivia') card_2 = Card("What is the first name of the character that wins Dungeons and Dragons in the first D&D episode?", "pierce", 'Community Trivia') card_3 = Card("What is the slogan of the STD fair?", "catch knowledge", 'Community Trivia') card_4 = Card('According to Greek mythology, who was the first woman on Earth?', 'pandora', 'Random Trivia') card_5 = Card('Two US States dont recognize daylight savings. Hawaii is one. What is the other?', 'arizona', 'Random Trivia') card_6 = Card('The ____ is the loudest animal on Earth.', 'sperm whale', 'Random Trivia') cards = [card_1, card_2, card_3, card_4, card_5, card_6] deck = Deck(cards) round = Round(deck) total_cards = len(cards) categories = deck.all_categories() intro = "Welcome to Flashcards! You are playing with %s cards" % total_cards print(intro) while len(cards) > 0: print('*-*-*-*-*-*-*-*-*-*-*-*-*-*-*') print('This is card number %s out of %s' % (total_cards - len(cards) + 1, total_cards)) print('Question: %s' % round.current_card().question) guess = input('>>').lower() guess = round.take_turn(guess) answer = guess.card.answer print("%s" % round.turns[-1].feedback())