Best Python code snippet using autotest_python
generate_readme.py
Source:generate_readme.py
...13 return '[' + name + ']' if name in name_to_links else name14def print_generated_projects():15 global nongames16 global games17 def print_projects(year_to_projects):18 for year, projects in year_to_projects.items():19 print('### ' + str(year))20 for p in projects:21 print('{:s} - {:s}\n'.format(22 md_bold(md_link_project(p['name'])),23 p['description']))24 tagline = []25 if 'languages' in p:26 tagline.append(27 'languages: **_{:s}_**'.format(', '.join(p['languages'])))28 if 'technologies' in p:29 tagline.append(30 'technologies: **_{:s}_**'.format(', '.join(p['technologies'])))31 for tag in tagline:32 print(' * ' + tag)33 print('\n')34 print_projects(nongames)35 print('## Games')36 print_projects(games)37def print_generated_link_references():38 global name_to_links39 print('[//]: #')40 for name, link in name_to_links.items():41 print('[{:s}]:<{:s}>'.format(name, link))42def main():43 PROJECTS_JSON_FILENAME = 'projects.json'44 MD_BEGIN = """# **Projects**45My projects and their Github links.46Organized into [projects](#projects) and [games](#games) sorted chronologically.47"""48 MD_END = """## Thanks for visiting!49If you have any questions, you can send me a message or reach me at nickwu@alumni.ubc.ca.50"""...
projektu_valdymas.py
Source:projektu_valdymas.py
1from projekto_modelis import Projektas, engine2from sqlalchemy.orm import sessionmaker3session = sessionmaker(bind=engine)()4def print_projects():5 print("--- PROJEKTAI ---")6 print("(#, Pavadinimas, Kaina, Sukurta)")7 projects = session.query(Projektas).all()8 for project in projects:9 print(project)10def new_project():11 print("--- Naujas Projektas ---")12 try:13 name = input("Pavadinimas: ")14 price = float(input("Kaina: "))15 except ValueError:16 print("KLAIDA: Kaina turi bÅ«ti skaiÄius.")17 return18 else:19 project = Projektas(name, price)20 session.add(project)21 session.commit()22 print(f"Projektas {project} sukurtas sÄkmingai")23def input_project():24 print_projects()25 try:26 project_id = int(input("Ä®veskite projekto ID: "))27 except ValueError:28 print("KLAIDA: ID turi bÅ«ti skaiÄius.")29 return None30 else:31 if project_id:32 project = session.query(Projektas).get(project_id)33 if project:34 return project35 else:36 print(f"KLAIDA: Projektas su ID: {project_id} neegzistuoja.")37 return None38def update_project():39 project = input_project()40 if project:41 try:42 name = input(f"Pavadinimas ({project.name}): ")43 price = float(input(f"Kaina ({project.price}): ") or 0)44 except ValueError:45 print("KLAIDA: kaina turi bÅ«ti skaiÄius.")46 return47 else:48 if len(name) > 0:49 project.name = name50 if price:51 project.price = price52 session.commit()53 print(f"Projektas {project} atnaujintas sÄkmingai.")54def delete_project():55 trinamas = input_project()56 if trinamas:57 session.delete(trinamas)58 session.commit()59 print(f"Projektas {trinamas} iÅ¡trintas sÄkmingai")60while True:61 print("=== Projektų valdymo duomenų bazÄ ===")62 print("- q: iÅ¡eiti")63 print("- r: rodyti visus projektus")64 print("- n: naujas projektas")65 print("- u: pakeisti projekto duomenis")66 print("- d: trinti projektÄ
")67 pasirinkimas = input("Pasirinkite: ").casefold()68 if pasirinkimas == "q":69 print("Viso gero!")70 break71 elif pasirinkimas == "r":72 print_projects()73 elif pasirinkimas == "n":74 new_project()75 elif pasirinkimas == "u":76 update_project()77 elif pasirinkimas == "d":78 delete_project()79 else:...
4_7_buildOrder.py
Source:4_7_buildOrder.py
...44 project = self.projects[i[0]]45 dependency = self.projects[i[1]]46 project.dependencies.append(dependency)47 dependency.incoming_dependencies += 148 def print_projects(self, arr):49 for i in arr:50 print(i.node)51class Test(unittest.TestCase):52 def setUp(self):53 Project.projects = {}54 def test_add_projects(self):55 dep = [["a", "d"], ["f", "b"], ["f", "a"]]56 p = Project(dep)57 def test_buildOrder(self):58 dep = [["a", "d"], ["f", "a"]]59 p = Project(dep)60 # p.print_projects(p.buildOrder())61 self.assertEqual(["f", "a", "d"], p.buildOrder())62 def test_buildOrder_cycle(self):63 dep = [["a", "d"], ["d", "a"]]64 p = Project(dep)65 # p.print_projects(p.buildOrder())66 with self.assertRaises(Exception):...
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!!