How to use test4 method in avocado

Best Python code snippet using avocado_python

test.py

Source:test.py Github

copy

Full Screen

1from subprocess import Popen, PIPE2from unittest import TestCase3import signal4import threading5import random6import logging7# use `sudo lsof -i -P -n` to make sure all processes have been terminated8def get_random_string():9 return "-" + str(random.randrange(0, 100000))10TIME_INTERVAL = 1 # in seconds11testcase = TestCase()12CLIENT1 = "client1" + get_random_string()13CLIENT2 = "client2" + get_random_string()14UNKNOWNCLIENT = "unknownClient" + get_random_string()15MESSAGE1 = "message1" + get_random_string()16MESSAGE2 = "message2" + get_random_string()17CLEANUP_COMMANDS = ["pkill -f python",18 "pkill -f Python"19 ]20# constants for test 121TEST1_SERVER_PORT = str(random.randrange(6600, 9000))22TEST1_COMMANDS = ["python3 server.py -p " + TEST1_SERVER_PORT,23 "python3 client.py -s 127.0.0.1 -p " + TEST1_SERVER_PORT + " -n " + CLIENT124 ]25TEST1_SERVER_INPUTS = []26TEST1_CLIENT_INPUTS = ["exit"]27TEST1_EXPECTED_SERVER_OUTPUTS = ["server started on 127.0.0.1 at port " + TEST1_SERVER_PORT,28 CLIENT1 + " registered from host 127.0.0.1 port "29 ]30TEST1_EXPECTED_CLIENT_OUTPUTS = ["connected to server and registered " + CLIENT1,31 "terminating client..."32 ]33# constants for test234TEST2_SERVER_PORT = str(random.randrange(6600, 9000))35TEST2_COMMANDS = ["python3 server.py -p " + TEST2_SERVER_PORT,36 "python3 client.py -s 127.0.0.1 -p " + TEST2_SERVER_PORT + " -n " + CLIENT1,37 "python3 client.py -s 127.0.0.1 -p " + TEST2_SERVER_PORT + " -n " + CLIENT238 ]39TEST2_SERVER_INPUTS = []40TEST2_CLIENT1_INPUTS = []41TEST2_CLIENT2_INPUTS = []42TEST2_EXPECTED_SERVER_OUTPUTS = ["server started on 127.0.0.1 at port " + TEST2_SERVER_PORT,43 CLIENT1 + " registered from host 127.0.0.1 port ",44 CLIENT2 + " registered from host 127.0.0.1 port "45 ]46TEST2_EXPECTED_CLIENT1_OUTPUTS = ["connected to server and registered " + CLIENT147 ]48TEST2_EXPECTED_CLIENT2_OUTPUTS = ["connected to server and registered " + CLIENT249 ]50# constants for test351TEST3_SERVER_PORT = str(random.randrange(6600, 9000))52TEST3_COMMANDS = ["python3 server.py -p " + TEST3_SERVER_PORT,53 "python3 client.py -s 127.0.0.1 -p " + TEST3_SERVER_PORT + " -n " + CLIENT1,54 "python3 client.py -s 127.0.0.1 -p " + TEST3_SERVER_PORT + " -n " + CLIENT255 ]56TEST3_SERVER_INPUTS = []57TEST3_CLIENT1_INPUTS = ["sendto " + CLIENT2 + " " + MESSAGE1,58 "sendto " + UNKNOWNCLIENT + " " + MESSAGE259 ]60TEST3_CLIENT2_INPUTS = []61TEST3_EXPECTED_SERVER_OUTPUTS = ["server started on 127.0.0.1 at port " + TEST3_SERVER_PORT,62 CLIENT1 + " registered from host 127.0.0.1 port ",63 CLIENT2 + " registered from host 127.0.0.1 port ",64 CLIENT1 + " to " + CLIENT2 + ": " + MESSAGE1,65 CLIENT1 + " to " + UNKNOWNCLIENT + ": " + MESSAGE2,66 UNKNOWNCLIENT + " is not registered with server"67 ]68TEST3_EXPECTED_CLIENT1_OUTPUTS = ["connected to server and registered " + CLIENT169 ]70TEST3_EXPECTED_CLIENT2_OUTPUTS = ["connected to server and registered " + CLIENT2,71 CLIENT1 + ": " + MESSAGE172 ]73# constants for test474TEST4_SERVER1_PORT = str(random.randrange(6600, 9000))75TEST4_SERVER2_PORT = str(random.randrange(6600, 9000))76TEST4_SERVER1_OVERLAY_PORT = str(random.randrange(6600, 9000))77TEST4_SERVER2_OVERLAY_PORT = str(random.randrange(6600, 9000))78TEST4_COMMANDS = ["python3 server.py -p " + TEST4_SERVER1_PORT + " -o " + TEST4_SERVER1_OVERLAY_PORT,79 "python3 server.py -p " + TEST4_SERVER2_PORT + " -s 127.0.0.1 -t " + TEST4_SERVER1_OVERLAY_PORT + " -o " + TEST4_SERVER2_OVERLAY_PORT,80 "python3 client.py -s 127.0.0.1 -p " + TEST4_SERVER1_PORT + " -n " + CLIENT1,81 "python3 client.py -s 127.0.0.1 -p " + TEST4_SERVER2_PORT + " -n " + CLIENT282 ]83TEST4_SERVER1_INPUTS = []84TEST4_SERVER2_INPUTS = []85TEST4_CLIENT1_INPUTS = ["sendto " + CLIENT2 + " " + MESSAGE186 ]87TEST4_CLIENT2_INPUTS = []88TEST4_EXPECTED_SERVER1_OUTPUTS = ["server started on 127.0.0.1 at port " + TEST4_SERVER1_PORT,89 "server overlay started at port " + TEST4_SERVER1_OVERLAY_PORT,90 "server overlay connection from host 127.0.0.1 port ",91 CLIENT1 + " registered from host 127.0.0.1 port ",92 CLIENT1 + " to " + CLIENT2 + ": " + MESSAGE1,93 CLIENT2 + " is not registered with server",94 "Sending message to overlay server: " + CLIENT1 + " to " + CLIENT2 + ": " + MESSAGE195 ]96TEST4_EXPECTED_SERVER2_OUTPUTS = ["server started on 127.0.0.1 at port " + TEST4_SERVER2_PORT,97 "server overlay started at port " + TEST4_SERVER2_OVERLAY_PORT,98 "connected to overlay server at 127.0.0.1 port " + TEST4_SERVER1_OVERLAY_PORT,99 CLIENT2 + " registered from host 127.0.0.1 port ",100 "Received from overlay server: " + CLIENT1 + " to " + CLIENT2 + ": " + MESSAGE1101 ]102TEST4_EXPECTED_CLIENT1_OUTPUTS = ["connected to server and registered " + CLIENT1103 ]104TEST4_EXPECTED_CLIENT2_OUTPUTS = ["connected to server and registered " + CLIENT2,105 CLIENT1 + ": " + MESSAGE1106 ]107# constants for test5108TEST5_SERVER1_PORT = str(random.randrange(6600, 9000))109TEST5_SERVER2_PORT = str(random.randrange(6600, 9000))110TEST5_SERVER1_OVERLAY_PORT = str(random.randrange(6600, 9000))111TEST5_SERVER2_OVERLAY_PORT = str(random.randrange(6600, 9000))112TEST5_COMMANDS = ["python3 server.py -p " + TEST5_SERVER1_PORT + " -o " + TEST5_SERVER1_OVERLAY_PORT,113 "python3 server.py -p " + TEST5_SERVER2_PORT + " -s 127.0.0.1 -t " + TEST5_SERVER1_OVERLAY_PORT + " -o " + TEST5_SERVER2_OVERLAY_PORT,114 "python3 client.py -s 127.0.0.1 -p " + TEST5_SERVER1_PORT + " -n " + CLIENT1,115 "python3 client.py -s 127.0.0.1 -p " + TEST5_SERVER2_PORT + " -n " + CLIENT2116 ]117TEST5_SERVER1_INPUTS = []118TEST5_SERVER2_INPUTS = []119TEST5_CLIENT1_INPUTS = ["sendto " + CLIENT2 + " " + MESSAGE1120 ]121TEST5_CLIENT2_INPUTS = ["sendto " + CLIENT1 + " " + MESSAGE2122 ]123TEST5_EXPECTED_SERVER1_OUTPUTS = ["server started on 127.0.0.1 at port " + TEST5_SERVER1_PORT,124 "server overlay started at port " + TEST5_SERVER1_OVERLAY_PORT,125 "server overlay connection from host 127.0.0.1 port ",126 CLIENT1 + " registered from host 127.0.0.1 port ",127 CLIENT1 + " to " + CLIENT2 + ": " + MESSAGE1,128 CLIENT2 + " is not registered with server",129 "Sending message to overlay server: " + CLIENT1 + " to " + CLIENT2 + ": " + MESSAGE1,130 "Received from overlay server: " + CLIENT2 + " to " + CLIENT1 + ": " + MESSAGE2131 ]132TEST5_EXPECTED_SERVER2_OUTPUTS = ["server started on 127.0.0.1 at port " + TEST5_SERVER2_PORT,133 "server overlay started at port " + TEST5_SERVER2_OVERLAY_PORT,134 "connected to overlay server at 127.0.0.1 port " + TEST5_SERVER1_OVERLAY_PORT,135 CLIENT2 + " registered from host 127.0.0.1 port ",136 "Received from overlay server: " + CLIENT1 + " to " + CLIENT2 + ": " + MESSAGE1,137 CLIENT2 + " to " + CLIENT1 + ": " + MESSAGE2,138 CLIENT1 + " is not registered with server",139 "Sending message to overlay server: " + CLIENT2 + " to " + CLIENT1 + ": " + MESSAGE2140 ]141TEST5_EXPECTED_CLIENT1_OUTPUTS = ["connected to server and registered " + CLIENT1,142 CLIENT2 + ": " + MESSAGE2143 ]144TEST5_EXPECTED_CLIENT2_OUTPUTS = ["connected to server and registered " + CLIENT2,145 CLIENT1 + ": " + MESSAGE1146 ]147TEST_COMMANDS = [TEST1_COMMANDS, TEST2_COMMANDS, TEST3_COMMANDS, TEST4_COMMANDS, TEST5_COMMANDS]148TEST_INPUTS = [[TEST1_SERVER_INPUTS, TEST1_CLIENT_INPUTS],149 [TEST2_SERVER_INPUTS, TEST2_CLIENT1_INPUTS, TEST2_CLIENT2_INPUTS],150 [TEST3_SERVER_INPUTS, TEST3_CLIENT1_INPUTS, TEST3_CLIENT2_INPUTS],151 [TEST4_SERVER1_INPUTS,TEST4_SERVER2_INPUTS, TEST4_CLIENT1_INPUTS, TEST4_CLIENT2_INPUTS],152 [TEST5_SERVER1_INPUTS,TEST5_SERVER2_INPUTS, TEST5_CLIENT1_INPUTS, TEST5_CLIENT2_INPUTS]153 ]154EXPECTED_OUTPUTS = [[TEST1_EXPECTED_SERVER_OUTPUTS, TEST1_EXPECTED_CLIENT_OUTPUTS],155 [TEST2_EXPECTED_SERVER_OUTPUTS, TEST2_EXPECTED_CLIENT1_OUTPUTS, TEST2_EXPECTED_CLIENT2_OUTPUTS],156 [TEST3_EXPECTED_SERVER_OUTPUTS, TEST3_EXPECTED_CLIENT1_OUTPUTS, TEST3_EXPECTED_CLIENT2_OUTPUTS],157 [TEST4_EXPECTED_SERVER1_OUTPUTS, TEST4_EXPECTED_SERVER2_OUTPUTS, TEST4_EXPECTED_CLIENT1_OUTPUTS, TEST4_EXPECTED_CLIENT2_OUTPUTS],158 [TEST5_EXPECTED_SERVER1_OUTPUTS, TEST5_EXPECTED_SERVER2_OUTPUTS, TEST5_EXPECTED_CLIENT1_OUTPUTS, TEST5_EXPECTED_CLIENT2_OUTPUTS]159 ]160class TimeoutException(Exception):161 def __init__(self):162 super().__init__()163def handler(signum, frame):164 raise TimeoutException()165def run_process(process):166 signal.signal(signal.SIGALRM, handler)167 try:168 signal.alarm(TIME_INTERVAL) # timeout after TIME_INTERVAL (in seconds)169 process.wait()170 except TimeoutException:171 pass172 finally:173 signal.alarm(0)174def create_processes(commands, processes):175 for cmd in commands:176 process = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)177 processes.append(process)178 run_process(process)179def run_processes(processes):180 for process in processes:181 run_process(process)182def write_to_console(processes, inputs):183 for i in range(len(processes)):184 for line in inputs[i]:185 line += "\n"186 processes[i].stdin.write(line.encode("utf-8"))187 processes[i].stdin.flush()188 run_process(processes[i])189def check_console_messages(processes, outputs):190 signal.signal(signal.SIGALRM, handler)191 for i in range(len(processes)):192 counter = 0193 try:194 signal.alarm(TIME_INTERVAL) # timeout after TIME_INTERVAL (in seconds)195 processes[i].stdout.flush()196 for line in processes[i].stdout:197 line = line.decode("utf-8").strip()198 if not (line.isspace() or line == ""):199 testcase.assertIn(outputs[i][counter], line)200 counter += 1201 except TimeoutException:202 # make sure that all expected lines are present203 testcase.assertEqual(counter, len(outputs[i]))204 pass205 finally:206 signal.alarm(0)207def kill_processes(processes):208 for process in processes:209 process.kill()210def cleanup():211 create_processes(CLEANUP_COMMANDS, [])212def check_results_and_cleanup(processes, outputs, identifier):213 try:214 check_console_messages(processes, outputs)215 print(identifier + " PASSED. CONGRATS!")216 return 20217 except AssertionError as e:218 errorMsg = str(e)219 if "!=" in errorMsg:220 logging.error(identifier + " FAILED: Missing console statements: " + str(e))221 else:222 logging.error(identifier + " FAILED: " + str(e))223 print(identifier + " FAILED.")224 return 0225 finally:226 kill_processes(processes)227 cleanup()228def run_tests():229 points = 0230 for i in range(len(TEST_COMMANDS)):231 processes = []232 create_processes(TEST_COMMANDS[i], processes)233 write_to_console(processes, TEST_INPUTS[i])234 run_processes(processes)235 points += check_results_and_cleanup(processes, EXPECTED_OUTPUTS[i], "TEST" + str(i+1))236 return points237if __name__ == "__main__":...

Full Screen

Full Screen

test_unittest.py

Source:test_unittest.py Github

copy

Full Screen

1#!/usr/bin/python2#3# Copyright 2008 Google Inc. All Rights Reserved.4"""Tests for test."""5import unittest, sys, os6import common7from autotest_lib.cli import cli_mock, topic_common, test8from autotest_lib.client.common_lib import control_data9CLIENT = control_data.CONTROL_TYPE_NAMES.CLIENT10SERVER = control_data.CONTROL_TYPE_NAMES.SERVER11class test_list_unittest(cli_mock.cli_unittest):12 values = [{u'description': u'unknown',13 u'test_type': CLIENT,14 u'test_class': u'Canned Test Sets',15 u'path': u'client/tests/test0/control',16 u'synch_type': u'Asynchronous',17 u'id': 138,18 u'name': u'test0',19 u'experimental': False},20 {u'description': u'unknown',21 u'test_type': SERVER,22 u'test_class': u'Kernel',23 u'path': u'server/tests/test1/control',24 u'synch_type': u'Asynchronous',25 u'id': 139,26 u'name': u'test1',27 u'experimental': False},28 {u'description': u'unknown',29 u'test_type': CLIENT,30 u'test_class': u'Canned Test Sets',31 u'path': u'client/tests/test2/control.readprofile',32 u'synch_type': u'Asynchronous',33 u'id': 140,34 u'name': u'test2',35 u'experimental': False},36 {u'description': u'unknown',37 u'test_type': SERVER,38 u'test_class': u'Canned Test Sets',39 u'path': u'server/tests/test3/control',40 u'synch_type': u'Asynchronous',41 u'id': 142,42 u'name': u'test3',43 u'experimental': False},44 {u'description': u'Random stuff to check that things are ok',45 u'test_type': CLIENT,46 u'test_class': u'Hardware',47 u'path': u'client/tests/test4/control.export',48 u'synch_type': u'Asynchronous',49 u'id': 143,50 u'name': u'test4',51 u'experimental': True}]52 def test_test_list_tests_default(self):53 self.run_cmd(argv=['atest', 'test', 'list'],54 rpcs=[('get_tests', {'experimental': False},55 True, self.values)],56 out_words_ok=['test0', 'test1', 'test2',57 'test3', 'test4'],58 out_words_no=['Random', 'control.export'])59 def test_test_list_tests_all(self):60 self.run_cmd(argv=['atest', 'test', 'list', '--all'],61 rpcs=[('get_tests', {},62 True, self.values)],63 out_words_ok=['test0', 'test1', 'test2',64 'test3', 'test4'],65 out_words_no=['Random', 'control.export'])66 def test_test_list_tests_exp(self):67 self.run_cmd(argv=['atest', 'test', 'list', '--experimental'],68 rpcs=[('get_tests', {'experimental': True},69 True,70 [{u'description': u'Random stuff',71 u'test_type': CLIENT,72 u'test_class': u'Hardware',73 u'path': u'client/tests/test4/control.export',74 u'synch_type': u'Asynchronous',75 u'id': 143,76 u'name': u'test4',77 u'experimental': True}])],78 out_words_ok=['test4'],79 out_words_no=['Random', 'control.export'])80 def test_test_list_tests_select_one(self):81 filtered = [val for val in self.values if val['name'] in ['test3']]82 self.run_cmd(argv=['atest', 'test', 'list', 'test3'],83 rpcs=[('get_tests', {'name__in': ['test3'],84 'experimental': False},85 True, filtered)],86 out_words_ok=['test3'],87 out_words_no=['test0', 'test1', 'test2', 'test4',88 'unknown'])89 def test_test_list_tests_select_two(self):90 filtered = [val for val in self.values91 if val['name'] in ['test3', 'test1']]92 self.run_cmd(argv=['atest', 'test', 'list', 'test3,test1'],93 rpcs=[('get_tests', {'name__in': ['test1', 'test3'],94 'experimental': False},95 True, filtered)],96 out_words_ok=['test3', 'test1', SERVER],97 out_words_no=['test0', 'test2', 'test4',98 'unknown', CLIENT])99 def test_test_list_tests_select_two_space(self):100 filtered = [val for val in self.values101 if val['name'] in ['test3', 'test1']]102 self.run_cmd(argv=['atest', 'test', 'list', 'test3', 'test1'],103 rpcs=[('get_tests', {'name__in': ['test1', 'test3'],104 'experimental': False},105 True, filtered)],106 out_words_ok=['test3', 'test1', SERVER],107 out_words_no=['test0', 'test2', 'test4',108 'unknown', CLIENT])109 def test_test_list_tests_all_verbose(self):110 self.run_cmd(argv=['atest', 'test', 'list', '-v'],111 rpcs=[('get_tests', {'experimental': False},112 True, self.values)],113 out_words_ok=['test0', 'test1', 'test2',114 'test3', 'test4', 'client/tests',115 'server/tests'],116 out_words_no=['Random'])117 def test_test_list_tests_all_desc(self):118 self.run_cmd(argv=['atest', 'test', 'list', '-d'],119 rpcs=[('get_tests', {'experimental': False},120 True, self.values)],121 out_words_ok=['test0', 'test1', 'test2',122 'test3', 'test4', 'unknown', 'Random'],123 out_words_no=['client/tests', 'server/tests'])124 def test_test_list_tests_all_desc_verbose(self):125 self.run_cmd(argv=['atest', 'test', 'list', '-d', '-v'],126 rpcs=[('get_tests', {'experimental': False},127 True, self.values)],128 out_words_ok=['test0', 'test1', 'test2',129 'test3', 'test4', 'client/tests',130 'server/tests', 'unknown', 'Random' ])131if __name__ == '__main__':...

Full Screen

Full Screen

test_command_remove_dup.py

Source:test_command_remove_dup.py Github

copy

Full Screen

1import shutil2import time3import os4import pytest5from tests.utils import remove_file6from sqlalchemy import and_7from photomanager.lib.pmconst import PM_TODO_LIST, PMDBNAME8from photomanager.commands.index import CommandIndex 9from photomanager.commands.remove_dup import CommandRemoveDuplicate10from photomanager.db.dbutils import get_db_session11from photomanager.controller.controller_file_dup import RemoveDupFilesDoer12from photomanager.lib import errors13from photomanager.db.models import ImageMeta14cmd_inx_test_root = 'tests/data'15default_backup_dir = cmd_inx_test_root + "/../photomanager_backup"16class TestRemoveDup(object):17 db_session = None18 @staticmethod19 def _clear():20 shutil.rmtree(default_backup_dir, ignore_errors=True)21 remove_file(cmd_inx_test_root + '/' + PM_TODO_LIST)22 remove_file(cmd_inx_test_root + '/' + "test_new.jpg")23 @staticmethod24 def _copy_dup_files():25 shutil.copy(f"{cmd_inx_test_root}/test4.jpg", f"{cmd_inx_test_root}/test4_dup.jpg")26 shutil.copy(f"{cmd_inx_test_root}/test4.jpg", f"{cmd_inx_test_root}/subdir/test4_dup.jpg")27 time.sleep(0.5)28 @staticmethod29 def _do_index():30 command_index = CommandIndex(cmd_inx_test_root, {})31 cnt = command_index.do()32 @classmethod33 def setup_class(cls):34 cls._copy_dup_files()35 cls._do_index()36 @classmethod37 def teardown_class(cls):38 cls._clear()39 remove_file(cmd_inx_test_root + '/' + PMDBNAME)40 def setup_method(self):41 self._clear()42 def teardown_method(self):43 self._clear()44 def test_list_dup(self):45 cmd_dup = CommandRemoveDuplicate(cmd_inx_test_root, {})46 dup_list = cmd_dup._list_duplicate()47 expect_data = {48 '4a298b2c1e0b9d02550d8f3a32b5b2d3': [('', 'test4.jpg'), ('', 'test4_dup.jpg'), ('subdir', 'test4_dup.jpg')]49 }50 assert(dup_list == expect_data)51 def test_remove_dups_error(self):52 dup_files = [('', 'test4.jpg'), ('', 'test4_dup.jpg'), ('subdir', 'test4_dup.jpg')]53 db_session = get_db_session(cmd_inx_test_root + '/' + PMDBNAME)54 remove_dup_ctr = RemoveDupFilesDoer(cmd_inx_test_root, db_session, dup_files)55 with pytest.raises(errors.RemoveImageIndexOutofRangeError) as exc_info:56 remove_dup_ctr.delete([-1])57 assert exc_info.value.error_code == 4000158 with pytest.raises(errors.RemoveImageCannotRemoveAllError) as exc_info:59 remove_dup_ctr.delete([0, 1, 2])60 assert exc_info.value.error_code == 4000261 def test_remove_dups(self):62 dup_files = [('', 'test4.jpg'), ('', 'test4_dup.jpg'), ('subdir', 'test4_dup.jpg')]63 db_session = get_db_session(cmd_inx_test_root + '/' + PMDBNAME)64 remove_dup_ctr = RemoveDupFilesDoer(cmd_inx_test_root, db_session, dup_files)65 cnt = remove_dup_ctr.delete([1,2])66 assert(cnt == 2)67 assert (os.path.exists(default_backup_dir + "/subdir/test4_dup.jpg"))68 assert (not os.path.exists(cmd_inx_test_root + "/subdir/test4_dup.jpg"))69 assert (not os.path.exists(cmd_inx_test_root + "/test4_dup.jpg"))70 assert (os.path.exists(cmd_inx_test_root + "/test4.jpg"))71 imgs = db_session.query(ImageMeta).filter(72 and_(ImageMeta.folder == "subdir", ImageMeta.filename == "tset4_dup.jpg")).all()...

Full Screen

Full Screen

suggestions.py

Source:suggestions.py Github

copy

Full Screen

1import pandas as pd 2import warnings3warnings.simplefilter("ignore") 4# Get the data 5column_names = ['user_id', 'item_id', 'rating', 'timestamp'] 6 7path = 'https://media.geeksforgeeks.org/wp-content/uploads/file.tsv'8 9df = pd.read_csv(path, sep='\t', names=column_names) 10 11# Check the head of the data 12print(df.head())13print()14# Check out all the movies and their respective IDs 15movie_titles = pd.read_csv('https://media.geeksforgeeks.org/wp-content/uploads/Movie_Id_Titles.csv') 16movie_titles.head() 17df = pd.merge(df, movie_titles, on='item_id') 18print(df.head())19print() 20print(df.describe())21ratings = pd.DataFrame(df.groupby('title')['rating'].mean())22print(ratings.head())23print()24ratings = ratings.sort_values('rating', ascending = False)25print(ratings.head())26print()27test1 = df[df["user_id"] == 0]28test3 = test1[test1["rating"] == 5]29test4 = test3["title"][0][:100]30print(test4 + "\n")31#print(test5 + "\n")32print(test3)33#print(test5)34movie_matrix = df.pivot_table(index='user_id', columns='title', values='rating')35movie_matrix.head()36test4_user_rating = movie_matrix[test4]37similar_to_test4=movie_matrix.corrwith(test4_user_rating)38print(similar_to_test4.head())39print()40corr_test4 = pd.DataFrame(similar_to_test4, columns=['correlation'])41corr_test4.dropna(inplace=True)42print(corr_test4.head())43print()44print("Hello")45for i in corr_test4:46 for j in corr_test4:47 print(corr_test4[i][j])...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful