Best Python code snippet using localstack_python
view.py
Source:view.py  
...29            date = input("Please enter a date (Y M D) : ")30            date = date.split()31            if not len(date) == 3:32                print("you need to enter a year, month and day")33            if not self.test_is_number(date[0]):34                continue35            if not self.test_is_number(date[1]):36                continue37            if not self.test_is_number(date[2]):38                continue39            if not self.test_date_valid(date):40                continue41            date = date[0] + '-' + date[1] + '-' + date[2]42            number_of_rounds = input("Number of rounds : ")43            if number_of_rounds == "":44                number_of_rounds = 445            if not self.test_is_number(number_of_rounds):46                continue47            number_of_players = input("Number of players : ")48            if not self.test_is_number(number_of_players):49                continue50            if not self.test_at_least_four_players(number_of_players):51                continue52            if not self.test_number_of_player_is_even(number_of_players):53                continue54            time_control = input("Bullet, blitz or rapid tournament ? : ")55            time_control = time_control.capitalize()56            if not self.test_time_control_integrity(time_control):57                continue58            description = input("Enter a quick description of this tournament : ")59            print(60                '----------------------------------------------------------------------------------------------------')61            break62        return [name, place, date, int(number_of_rounds), int(number_of_players), time_control, description]63    def prompt_for_asking_player_name(self):64        while True:65            full_name = input("\nWhat is the full name of the player ? : ")66            if not self.test_only_letter(full_name):67                continue68            if not self.test_is_full_name(full_name):69                continue70            full_name.split()71            full_name[0].capitalize()72            full_name[1].capitalize()73            break74        return full_name75    def prompt_for_new_player(self, full_name):76        while True:77            print(78                '***********************************************')79            birthday_date = input("Please enter a Birthday date (Y M D) : ")80            birthday_date = birthday_date.split()81            if not len(birthday_date) == 3:82                print("you need to enter a year, month and day")83                continue84            if not self.test_is_number(birthday_date[0]):85                continue86            if not self.test_is_number(birthday_date[1]):87                continue88            if not self.test_is_number(birthday_date[2]):89                continue90            if not self.test_date_valid(birthday_date):91                continue92            birthday_date = birthday_date[0] + '-' + birthday_date[1] + '-' + birthday_date[2]93            gender = input("Gender :")94            if not self.test_first_as_letter(gender):95                continue96            gender = gender.capitalize()97            if not self.test_gender_format(gender):98                continue99            rank = input("Rank :")100            if not self.test_rank_integrity(rank):101                continue102            print("New player added successfully\n")103            print(104                '***********************************************')105            break106        new_player_infos = {'last_name': full_name[0], 'first_name': full_name[1], 'birthday_date': birthday_date,107                            'gender': gender, 'rank': rank}108        return new_player_infos109    def prompt_for_end_of_tournament(self, joueur, resultats):110        print(f'The score of {joueur} is {resultats}')111    def prompt_for_winner(self, pairing):112        while True:113            full_name = input(f"Who wins between {pairing[0]} and {pairing[1]} : ")114            if full_name == 'tie':115                break116            if not self.test_is_full_name(full_name):117                continue118            full_name.split()119            if not self.test_only_letter(full_name[0]) and self.test_only_letter(full_name[1]):120                continue121            break122        full_name[0].capitalize()123        full_name[1].capitalize()124        return full_name125    def prompt_menu(self):126        while True:127            print("----------------------------------------------------------------------------")128            print("1. New tournament")129            print("2. Change rank of a player")130            print("3. Add a player")131            print("4. Player's database")132            print("5. List all tournaments")133            print("6. List of all rounds in a tournament")134            print("7. Exit")135            print("----------------------------------------------------------------------------")136            choice = input("Your choice ? :")137            if not self.test_choice_menu(choice):138                continue139            break140        return int(choice)141    def prompt_menu_player_db(self):142        while True:143            print("1. Show all players")144            print("2. Research a player\n")145            choice = input("Choice : ")146            if not self.test_choice_player_db(choice):147                continue148            break149        return int(choice)150    def prompt_new_profile(self):151        print("\nThis player does not exist")152        print("Adding a new profile...\n")153    def prompt_profile_exist(self):154        print("Player found")155    def prompt_all_db_players(self, player, n=0):156        print(157            '-----------------------------------------------------------------------------------------------------\n')158        print(159            f"N° : {n} || Full name : {player['last_name']} {player['first_name']} ||"160            f" Birthday_date : {player['birthday_date']} || Gender {player['gender']} || rank : {player['rank']}")161    def prompt_all_tournaments(self, n, tournament):162        print(163            '-----------------------------------------------------------------------------------------------------')164        print(165            f"N° {n} || Name : {tournament['name']} || Place : {tournament['place']} || Date : {tournament['date']} ||"166            f" Number of rounds : {tournament['number_of_rounds']} || Time : {tournament['time_control']} ||"167            f" Description : {tournament['description']}\n")168    def prompt_all_rounds(self, index):169        print("-------------------------------------------------------------")170        print(f"Round {str(index + 1)} : ")171    def prompt_all_matchs(self, index, jindex, round):172        print(f"Match {str(jindex + 1)} || Name : "173              f"{round['Round ' + str(index + 1)][jindex]['match ' + str(jindex + 1)][0][0]['last_name']} "174              f"{round['Round ' + str(index + 1)][jindex]['match ' + str(jindex + 1)][0][0]['first_name']} "175              f"( {round['Round ' + str(index + 1)][jindex]['match ' + str(jindex + 1)][1][0]} ) "176              f"|| Name : ",177              f"{round['Round ' + str(index + 1)][jindex]['match ' + str(jindex + 1)][0][1]['last_name']} "178              f"{round['Round ' + str(index + 1)][jindex]['match ' + str(jindex + 1)][0][1]['first_name']} "179              f"( {round['Round ' + str(index + 1)][jindex]['match ' + str(jindex + 1)][1][1]} )")180    def prompt_asking_tournament_name(self):181        while True:182            name = input("Name of the tournament : ")183            if not self.test_first_as_letter(name):184                continue185            break186        return name187    def prompt_start_round(self, round, current_time):188        input(f"\nPress enter to start the round {round + 1}\n")189        print(f"Round {round + 1} has started at {current_time}\n")190    def prompt_end_round(self, round, current_time):191        print(f"\nEnd of round {round + 1} at {current_time}\n")192    def prompt_press_enter(self):193        input("\nPress enter to continue")194    def prompt_begin_pairing(self):195        key = input("Insert '*' to change the rank of a player or press enter to begin pairing")196        if key == "*":197            return True198        return False199    def prompt_new_rank(self):200        rank = -1201        while rank == -1:202            rank = input("What is the new rank of this player ?")203            if not self.test_rank_integrity(rank):204                continue205        return int(rank)206    def prompt_for_opponent(self, pair):207        print(f"\nplayer [{pair[0]}] plays against [{pair[1]}]")208    def test_first_as_letter(self, text):209        if 65 <= ord(text[0]) <= 90 or 97 <= ord(text[0]) <= 122:210            return True211        print("You need to begin with a letter")212        return False213    def test_time_control_integrity(self, time):214        if time == 'Blitz' or time == 'Bullet' or time == 'Rapid':215            return True216        else:217            print("You should choose between blitz, bullet or rapid")218            return False219    def test_is_number(self, number):220        try:221            int(number)222            return True223        except ValueError:224            print("This is not a number !")225            return False226    def test_is_full_name(self, full_name):227        try:228            if len(full_name.split()) == 2:229                return True230            else:231                print("Please enter a last_name and a first_name")232                return False233        except IndexError:...test_problem2.py
Source:test_problem2.py  
...5@author: kollisrivenkataphaniabhishek6"""7import problem28import pytest9def test_is_number():10    assert problem2.is_number("35") == True11    assert problem2.is_number("12") == True12#    assert problem2.is_number("-12") == False13    14def test_input_to_number():15    assert problem2.input_to_number("32") == 3216#    assert problem2.input_to_number("-12") == -1217    18def test_gcd_numbers():19    assert problem2.greatest_common_divisor(12, 3) == 320    assert problem2.greatest_common_divisor(97, 2) == 121pytest.main()22if __name__ == "__main__":23    test_is_number()24    test_input_to_number()25    test_gcd_numbers()26    27    ...test_common.py
Source:test_common.py  
1from common import is_number2def test_is_number():3    assert(is_number('29') == True)4    assert(is_number('sads') == False)5def test_all_common():...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
