Best Python code snippet using ATX
main.py
Source:main.py  
...154            profile_cmd.cmdloop()155        except Terminator:156            pass157        if profile_cmd.unregistered:158            return self.do_back(arg)159160    def do_setup(self, arg):161        try:162            setup_cmd = SetupShell()163            setup_cmd.cmdloop()164        except Terminator:165            pass166    167    def do_track(self, arg):168        try:169            track_cmd = TrackShell()170            track_cmd.cmdloop()171        except Terminator:172            pass173174    def do_back(self, arg):175        bye()176        return True177178179class ProfileShell(cmd.Cmd):180    prompt = "----------- APP PROFILE MENU -----------\nCOMMANDS:\n$password\n$update\n$caregiver\n$upgrade\n$unregister\n> "181    unregistered = False182183    def do_password(self, arg):184        new_password = input("New Password: ")185186        res = UserSystem.reset_password(new_password)187        if res:188            print("Success")189        else:190            print("Reset operation failed.")191    192    def do_update(self, arg):193        new_email = input("New Email: ")194        new_name = input("New Name: ")195196        UserSystem.reset_email(new_email)197        UserSystem.reset_name(new_name)198        print("Success")199    200    def do_unregister(self, arg):201        UserSystem.delete_current_user()202        print("Success")203        self.unregistered = True204        bye()205        return True206207    def do_caregiver(self, arg):208        email = input("Caregiver's email: ")209210    def do_upgrade(self, arg):211        print("TBD")212213    def do_back(self, arg):214        bye()215        return True216217# Setup menu to check stats or go back.218class SetupShell(cmd.Cmd):219    prompt = "----------- APP SETUP MENU -----------\nCOMMANDS:\n$stats\n$back\n> "220221    def do_stats(self, arg):222        try:223            stats_cmd = StatsShell()224            stats_cmd.cmdloop()225        except Terminator:226            pass227228229    def do_back(self, arg):230        bye()231        return True232233# User will be able to add stats, schedule, and go back. 234class StatsShell(cmd.Cmd):235    prompt = "----------- APP STATS MENU -----------\nCOMMANDS:\n$add\n$schedule\n$back\n> "236    237    def do_add(self, arg):238        tokens = arg.split(";")239240        if len(tokens) != 3:241            print("Error: arguments mismatch (3 required)")242        else:243            data_types = tokens[2].split(":")244            if " " in tokens[0]:245                print("Error: space found in first argument.")246            elif len(data_types) % 2 == 1:247                print("Error: Data types pair mismatch.")248            else:249                stat_types.append(tokens[0])250                print("Success")251252    def do_schedule(self, arg):253        tokens = arg.split()254        if len(tokens) != 3:255            print("Error: arguments mismatch (3 required)")256        elif tokens[1] != "UMTWRFS" or tokens[2] not in ['am', 'pm']:257            print("Usage: schedule [NAME] UMTWRFS [am/pm]")258        else:259            print("Success")260261    def do_back(self, arg):262        bye()263        return True264265# User is able to list, record, see report and go back.266class TrackShell(cmd.Cmd):267    prompt = "----------- APP TRACK MENU -----------\nCOMMANDS:\n$list\n$record\n$report\n$back\n> "268269    records = []270271    def do_list(self, arg):272        print("\n".join(stat_types))273274    def do_record(self, arg):275        self.records.append(arg)276        print("records appended")277278    def do_report(self, arg):279        print("showing records")280        print("\n".join(self.records))281282    def do_back(self, arg):283        bye()284        return True285286def parse(arg):287    'Convert a series of zero or more numbers to an argument tuple'288    return tuple(map(int, arg.split()))289290if __name__ == '__main__':
...test_back.py
Source:test_back.py  
...44        f = GT(Plus(r, Real(1)), Plus(s, Real(1)))45        term = msat.converter.convert(f)46        res = msat.converter.back(term)47        self.assertFalse(f == res)48    def do_back(self, solver_name, z3_string_buffer=False):49        for formula, _, _, logic in get_example_formulae():50            if logic.quantifier_free:51                if logic.theory.custom_type and z3_string_buffer:52                    # Printing of declare-sort from Z3 is not conformant53                    # with the SMT-LIB. We might consider extending our54                    # parser.55                    continue56                try:57                    s = Solver(name=solver_name, logic=logic)58                    term = s.converter.convert(formula)59                    if solver_name == "z3":60                        if z3_string_buffer:61                            res = s.converter.back_via_smtlib(term)62                        else:63                            res = s.converter.back(term)64                    else:65                        res = s.converter.back(term)66                    self.assertValid(Iff(formula, res), logic=logic,67                                     solver_name=solver_name)68                except NoSolverAvailableError:69                    pass70    @skipIfSolverNotAvailable("msat")71    def test_msat_back_formulae(self):72        self.do_back("msat")73    @skipIfSolverNotAvailable("z3")74    def test_z3_back_formulae(self):75        self.do_back("z3", z3_string_buffer=False)76        self.do_back("z3", z3_string_buffer=True)77if __name__ == '__main__':...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!!
