Best Python code snippet using lemoncheesecake
linked_lists_tests.py
Source:linked_lists_tests.py
1#!/usr/bin/env python2#-*- coding: utf-8 -*-34#import importlib5#moduleName = 'linked_lists'6#importlib.import_module(moduleName)78from linked_lists import *910def test_list(a):11 tmp = Node(0)12 try:13 a.delete(tmp.value)14 a.delete(tmp.value,True)15 print('\n find:',a.find(tmp))16 print('\n find all:',a.find_all(tmp.value))17 print('\n len:',a.len())18 a.insert(a.find(tmp),tmp)19 a.add_in_tail(tmp)20 print('\n All nodes: \n')21 a.print_all_nodes()22 a.clean()23 print('\n List is ok!')24 except:25 print('\n Something gone wrong!')2627n1 = Node(12)2829one_list = LinkedList()30empty_list = LinkedList()31many_list = LinkedList()32sum_list = LinkedList()33find_test = LinkedList()3435one_list.add_in_tail(n1)3637for i in range(100):38 many_list.add_in_tail(Node(i))3940test_list(one_list)41print('\n')42test_list(empty_list)43print('\n')44test_list(many_list)4546sum_list = sum_link_vals(many_list, many_list)47print('\n')48sum_list.print_all_nodes()4950for i in range(10):51 if i % 2 == 0:52 find_test.add_in_tail(Node(5))53 else:54 find_test.add_in_tail(Node(4))55find_test.add_in_tail(Node(3))56find_test.add_in_tail(Node(1))57find_test.insert(find_test.find(4),Node(2))58find_test.print_all_nodes()59print('found list:',find_test.find_all(find_test.find(Node(1)).value))
...
tests.py
Source:tests.py
1from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, DateTime, func2from sqlalchemy.ext.declarative import declarative_base3from sqlalchemy.orm import sessionmaker, relationship4Base = declarative_base()5engine = create_engine('mysql+pymysql://root:1234@127.0.0.1/sdo?charset=utf8', echo=True)6Session = sessionmaker(bind=engine)7def get_test(id):8 find_test = dict.fromkeys(['course_id', 'problems', 'owner', 'duration'])9 session = Session()10 for test in session.query(Tests).filter(Tests.id == id):11 find_test['course_id'] = test.course_id12 find_test['problems'] = test.problems13 find_test['owner'] = test.owner14 find_test['duration'] = test.duration15 session.commit()16 session.close()17 return find_test18class Tests(Base):19 __tablename__ = 'tests'20 id = Column(Integer, primary_key=True)21 course_id = Column(22 Integer,23 ForeignKey('courses.id'),24 nullable=False,25 )26 problems = Column(String(300))27 owner = Column(Integer)28 duration = Column(Integer)29 created_date = Column(DateTime(timezone=True), server_default=func.now())30 def __init__(self, course_id, problems, owner, duration):31 self.course_id = course_id32 self.problems = problems33 self.owner = owner34 self.duration = duration...
linked_lists_find_tests.py
Source:linked_lists_find_tests.py
1#!/usr/bin/env python2#-*- coding: utf-8 -*-34from linked_lists import *56def check_find(test_num,val,check_list,find_test):7 print('found list:',find_test.find_all(val),'\n')8 if len(find_test.find_all(val)) == len(check_list):9 print('Test ',test_num,' is ok!\n')10 else:11 print('Test ',test_num,' NOT ok!\n') 1213find_test = LinkedList()1415#Ñв ÑпиÑок пÑÑÑ16check_find(1.1,5,[],find_test)17check_find(1.2,5,[],find_test)1819#в Ñв ÑпиÑке 1 ÑлеменÑ20find_test.add_in_tail(Node(1))21check_find(2.1,1,[Node(1)],find_test)22check_find(2.2,5,[],find_test)2324#в Ñв ÑпиÑке много ÑлеменÑов25check_4 = []26check_5 = []27for i in range(100):28 if i % 2 == 0:29 find_test.add_in_tail(Node(5))30 check_5.append(Node(5))31 else:32 find_test.add_in_tail(Node(4))33 check_4.append(Node(4))34find_test.add_in_tail(Node(3))35find_test.add_in_tail(Node(1))36find_test.insert(find_test.find(4),Node(2))37#find_test.print_all_nodes()38check_find(3.1,0,[],find_test)39check_find(3.2,1,[Node(1),Node(1)],find_test)40check_find(3.3,3,[Node(3)],find_test)41check_find(3.4,4,check_4,find_test)
...
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!!