def main(): if len(sys.argv) > 1: name = sys.argv[1] else: name = "world" gr = Greeter(name) gr.greet()
def test_greet_notString_raises(self): greeter = Greeter() try: greeting = greeter.greet(10) except TypeError as e: return self.fail("No exception thrown")
#default is world #Author: Shubham Singh ([email protected]) from greeter import Greeter import sys if len(sys.argv) > 1: name = sys.argv[1] else: name = "world" gr = Greeter(name) gr.greet()
import os import time from greeter import Greeter from character_creator import CharacterCreator from character import Character import util if __name__ == '__main__': os.system('clear') greeter = Greeter("Hello, resident of Panem. Do you want to play a game? ") if greeter.greet(): print("Ok, next time!") else: creator = CharacterCreator() choose_player = input( "Great! \nPress 1 to create a custom player.\nPress 2 to randomly generate a player.\n" ) if choose_player == "1": player_character = creator.make_custom_character() else: player_character = creator.generate_random_character() os.system('clear') player_character.display() input("Press Enter to continue: ") os.system('clear') if player_character.district == 1 or player_character.district == 2 or player_character.district == 4: career = "lunge forward to volunteer." else:
def test_greeterTest(self): greeter = Greeter() greeting = greeter.greet("Juraj") self.assertEqual(greeting, "Hello, Juraj")
import sys from greeter import Greeter # Try/Except for argv/c try: name = sys.argv[1] except IndexError, NameError: print "Usage: python something_useful.py <name>" name = 'World' greeter = Greeter(name) # Prints name print greeter.greet()
def test_greet(self): greeter = Greeter() self.assertEqual("Hello, Joe", greeter.greet("Joe"))
def test_greet(self): greeter = Greeter('World!') self.assertEqual(greeter.greet(), 'Hello, World!')
# Author: Nadav Luzzato ([email protected]) import sys from greeter import Greeter name = "World" # Comment for git if (len(sys.argv) > 1): name = str(sys.argv[1]) greeter = Greeter(name) greeter.greet()
def test_greet(self, mock_time): mock_time.now.return_value.hour = 20 self.assertEqual(Greeter.greet("Ivan"), "Добрый вечер Ivan")
def test_logging_greet(self, mock_logger): name = Greeter.greet("Ivan") mock_logger.info.assert_called_with('You greeting with Ivan')
def test_good_night(self, mock_time): mock_time.now.return_value.hour = 23 self.assertEqual(Greeter.greet("Ivan"), "Доброй ночи Ivan")
def test_good_morning(self, mock_time): mock_time.now.return_value.hour = 7 self.assertEqual(Greeter.greet("Ivan"), "Доброе утро Ivan")
def test_greeter_returns_expected(self): greeter = Greeter() self.assertEqual(greeter.greet("Quentin"), "Hello, Quentin")