How to use is_relative method in avocado

Best Python code snippet using avocado_python

test_text2times.py

Source:test_text2times.py Github

copy

Full Screen

1#!/usr/bin/env python2#3# A unit test for the text2times module4import dstk5import json6dstk = dstk.DSTK()7test_input = ' \8January 1st 2000 \9thursday \10november \11friday 13:00 \12mon 2:35 \13friday 1pm \14yesterday \15today \16tomorrow \17this tuesday \18yesterday at 4:00 \19last friday at 20:00 \20tomorrow at 6:45pm \21January 5 \22dec 25 \23may 27th \24October 2006 \25oct 06 \26jan 3 2010 \27february 14, 2004 \283 jan 2007 \2917 april 85 \305/27/1979 \3127/5/1979 \3205/06 \331979-05-27 \34Friday \35January 5 at 7pm \361979-05-27 05:00:00 \371976\\05\\19 \38'39expected_output = [40 {"time_seconds": 946713600.0, "is_relative": False, "matched_string": "January 1st 2000", "end_index": 19, "time_string": "Sat Jan 01 00:00:00 -0800 2000", "duration": 86400, "start_index": 4}, 41 {"time_seconds": 947145600.0, "is_relative": True, "matched_string": "thursday", "end_index": 29, "time_string": "Thu Jan 06 00:00:00 -0800 2000", "duration": 86400, "start_index": 22}, 42 {"time_seconds": 973065600.0, "is_relative": True, "matched_string": "november", "end_index": 47, "time_string": "Wed Nov 01 00:00:00 -0800 2000", "duration": 2595600, "start_index": 40}, 43 {"time_seconds": 1302292800.0, "is_relative": False, "matched_string": "friday 13:00", "end_index": 69, "time_string": "Fri Apr 08 13:00:00 -0700 2011", "duration": 1, "start_index": 58}, 44 {"time_seconds": 946938900.0, "is_relative": True, "matched_string": "mon 2:35", "end_index": 83, "time_string": "Mon Jan 03 14:35:00 -0800 2000", "duration": 1, "start_index": 76}, 45 {"time_seconds": 947278800.0, "is_relative": True, "matched_string": "friday 1pm", "end_index": 103, "time_string": "Fri Jan 07 13:00:00 -0800 2000", "duration": 1, "start_index": 94}, 46 {"time_seconds": 946627200.0, "is_relative": True, "matched_string": "yesterday", "end_index": 120, "time_string": "Fri Dec 31 00:00:00 -0800 1999", "duration": 86400, "start_index": 112}, 47 {"time_seconds": 946717200.0, "is_relative": True, "matched_string": "today", "end_index": 134, "time_string": "Sat Jan 01 01:00:00 -0800 2000", "duration": 3600, "start_index": 130}, 48 {"time_seconds": 946800000.0, "is_relative": True, "matched_string": "tomorrow", "end_index": 155, "time_string": "Sun Jan 02 00:00:00 -0800 2000", "duration": 86400, "start_index": 148}, 49 {"time_seconds": 946972800.0, "is_relative": True, "matched_string": "this tuesday", "end_index": 177, "time_string": "Tue Jan 04 00:00:00 -0800 2000", "duration": 86400, "start_index": 166}, 50 {"time_seconds": 946684800.0, "is_relative": True, "matched_string": "yesterday at 4:00", "end_index": 200, "time_string": "Fri Dec 31 16:00:00 -0800 1999", "duration": 1, "start_index": 184}, 51 {"time_seconds": 1301713200.0, "is_relative": False, "matched_string": "last friday at 20:00", "end_index": 221, "time_string": "Fri Apr 01 20:00:00 -0700 2011", "duration": 1, "start_index": 202}, 52 {"time_seconds": 946867500.0, "is_relative": True, "matched_string": "tomorrow at 6:45pm", "end_index": 240, "time_string": "Sun Jan 02 18:45:00 -0800 2000", "duration": 1, "start_index": 223}, 53 {"time_seconds": 947059200.0, "is_relative": True, "matched_string": "January 5", "end_index": 250, "time_string": "Wed Jan 05 00:00:00 -0800 2000", "duration": 86400, "start_index": 242}, 54 {"time_seconds": 1324800000.0, "is_relative": False, "matched_string": "dec 25", "end_index": 265, "time_string": "Sun Dec 25 00:00:00 -0800 2011", "duration": 86400, "start_index": 260}, 55 {"time_seconds": 959410800.0, "is_relative": True, "matched_string": "may 27th", "end_index": 285, "time_string": "Sat May 27 00:00:00 -0700 2000", "duration": 86400, "start_index": 278}, 56 {"time_seconds": 1159686000.0, "is_relative": False, "matched_string": "October 2006", "end_index": 307, "time_string": "Sun Oct 01 00:00:00 -0700 2006", "duration": 2682000, "start_index": 296}, 57 {"time_seconds": 1317884400.0, "is_relative": False, "matched_string": "oct 06", "end_index": 319, "time_string": "Thu Oct 06 00:00:00 -0700 2011", "duration": 86400, "start_index": 314}, 58 {"time_seconds": 1262505600.0, "is_relative": False, "matched_string": "jan 3 2010", "end_index": 341, "time_string": "Sun Jan 03 00:00:00 -0800 2010", "duration": 86400, "start_index": 332}, 59 {"time_seconds": 1076745600.0, "is_relative": False, "matched_string": "february 14, 2004", "end_index": 366, "time_string": "Sat Feb 14 00:00:00 -0800 2004", "duration": 86400, "start_index": 350}, 60 {"time_seconds": 1167811200.0, "is_relative": False, "matched_string": "3 jan 2007", "end_index": 377, "time_string": "Wed Jan 03 00:00:00 -0800 2007", "duration": 86400, "start_index": 368}, 61 {"time_seconds": 482572800.0, "is_relative": False, "matched_string": "17 april 85", "end_index": 396, "time_string": "Wed Apr 17 00:00:00 -0800 1985", "duration": 86400, "start_index": 386}, 62 {"time_seconds": 296636400.0, "is_relative": False, "matched_string": "5/27/1979", "end_index": 412, "time_string": "Sun May 27 00:00:00 -0700 1979", "duration": 86400, "start_index": 404}, 63 {"time_seconds": 296636400.0, "is_relative": False, "matched_string": "27/5/1979", "end_index": 430, "time_string": "Sun May 27 00:00:00 -0700 1979", "duration": 86400, "start_index": 422}, 64 {"time_seconds": 1146466800.0, "is_relative": False, "matched_string": "05/06", "end_index": 444, "time_string": "Mon May 01 00:00:00 -0700 2006", "duration": 2678400, "start_index": 440}, 65 {"time_seconds": 296636400.0, "is_relative": False, "matched_string": "1979-05-27", "end_index": 467, "time_string": "Sun May 27 00:00:00 -0700 1979", "duration": 86400, "start_index": 458}, 66 {"time_seconds": 947127600.0, "is_relative": True, "matched_string": "January 5 at 7pm", "end_index": 509, "time_string": "Wed Jan 05 19:00:00 -0800 2000", "duration": 1, "start_index": 494}, 67 {"time_seconds": 296654400.0, "is_relative": False, "matched_string": "1979-05-27 05:00:00", "end_index": 530, "time_string": "Sun May 27 05:00:00 -0700 1979", "duration": 1, "start_index": 512}, 68 {"time_seconds": 201337200.0, "is_relative": False, "matched_string": "1976\\05\\19", "end_index": 541, "time_string": "Wed May 19 00:00:00 -0700 1976", "duration": 86400, "start_index": 532}69]70actual_output = dstk.text2times(test_input)71if len(expected_output) != len(actual_output):72 print json.dumps(actual_output)73 print('Expected '+str(len(expected_output))+' items, found '+str(len(actual_output)))74 exit(1)75for index, actual_item in enumerate(actual_output):76 expected_item = expected_output[index]77 if actual_item['time_seconds'] != expected_item['time_seconds']:78 print json.dumps(actual_output)79 print('Mismatch at item #'+str(index))80 exit(1)81 ...

Full Screen

Full Screen

practice5.py

Source:practice5.py Github

copy

Full Screen

1# 条件を動的に組み立てる2# 下記の例では、operation_companyとrailway_lineを条件にクエリを取得しています。3def get_dynamic_sql(name = None, is_relative = None):4 ret = []5 query = Person.select()6 cond = None7 if not name is None:8 cond = (Person.name == name)9 if not is_relative is None:10 if cond:11 cond = cond & (Person.is_relative == is_relative)12 else:13 cond = (Person.is_relative == is_relative)14 rows = query.where(cond)15 for r in rows: # ここでSQLを発行する16 ret.append(r.name)17 return ret18# この例ではパラメータの指定方法により4種類のSQLが作成されます。19# name=None,is_relative=None20# SELECT "t1"."id", "t1"."name", "t1"."birthday", "t1"."is_relative" FROM "person" AS "t121# name=None以外,is_relative=None22# SELECT "t1"."id", "t1"."name", "t1"."birthday", "t1"."is_relative" FROM "person" AS "t1" WHERE ("t1"."name" = ?)23# name=None,is_relative=None以外24# SELECT "t1"."id", "t1"."name", "t1"."birthday", "t1"."is_relative" FROM "person" AS "t1" WHERE ("t1"."is_relative" = ?)25# name=None以外,is_relative=None以外...

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