Best JavaScript code snippet using wpt
py00395ghost.py
Source:py00395ghost.py
...1134 game.global_vars[696] = 91135 game.global_flags[869] = 01136 game.quests[83].state = qs_completed1137 return RUN_DEFAULT1138def bye_bye( attachee, triggerer ):1139 attachee.object_flag_set(OF_OFF)...
toWarnDev-test.js
Source:toWarnDev-test.js
1/**2 * Copyright (c) Facebook, Inc. and its affiliates.3 *4 * This source code is licensed under the MIT license found in the5 * LICENSE file in the root directory of this source tree.6 *7 * @emails react-core8 */9'use strict';10describe('toErrorDev', () => {11 it('does not fail if a warning contains a stack', () => {12 expect(() => {13 if (__DEV__) {14 console.error('Hello\n in div');15 }16 }).toErrorDev('Hello');17 });18 it('does not fail if all warnings contain a stack', () => {19 expect(() => {20 if (__DEV__) {21 console.error('Hello\n in div');22 console.error('Good day\n in div');23 console.error('Bye\n in div');24 }25 }).toErrorDev(['Hello', 'Good day', 'Bye']);26 });27 it('does not fail if warnings without stack explicitly opt out', () => {28 expect(() => {29 if (__DEV__) {30 console.error('Hello');31 }32 }).toErrorDev('Hello', {withoutStack: true});33 expect(() => {34 if (__DEV__) {35 console.error('Hello');36 console.error('Good day');37 console.error('Bye');38 }39 }).toErrorDev(['Hello', 'Good day', 'Bye'], {withoutStack: true});40 });41 it('does not fail when expected stack-less warning number matches the actual one', () => {42 expect(() => {43 if (__DEV__) {44 console.error('Hello\n in div');45 console.error('Good day');46 console.error('Bye\n in div');47 }48 }).toErrorDev(['Hello', 'Good day', 'Bye'], {withoutStack: 1});49 });50 if (__DEV__) {51 // Helper methods avoids invalid toWarn().toThrow() nesting52 // See no-to-warn-dev-within-to-throw53 const expectToWarnAndToThrow = (expectBlock, expectedErrorMessage) => {54 let caughtError;55 try {56 expectBlock();57 } catch (error) {58 caughtError = error;59 }60 expect(caughtError).toBeDefined();61 expect(caughtError.message).toContain(expectedErrorMessage);62 };63 it('fails if a warning does not contain a stack', () => {64 expectToWarnAndToThrow(() => {65 expect(() => {66 console.error('Hello');67 }).toErrorDev('Hello');68 }, 'Received warning unexpectedly does not include a component stack');69 });70 it('fails if some warnings do not contain a stack', () => {71 expectToWarnAndToThrow(() => {72 expect(() => {73 console.error('Hello\n in div');74 console.error('Good day\n in div');75 console.error('Bye');76 }).toErrorDev(['Hello', 'Good day', 'Bye']);77 }, 'Received warning unexpectedly does not include a component stack');78 expectToWarnAndToThrow(() => {79 expect(() => {80 console.error('Hello');81 console.error('Good day\n in div');82 console.error('Bye\n in div');83 }).toErrorDev(['Hello', 'Good day', 'Bye']);84 }, 'Received warning unexpectedly does not include a component stack');85 expectToWarnAndToThrow(() => {86 expect(() => {87 console.error('Hello\n in div');88 console.error('Good day');89 console.error('Bye\n in div');90 }).toErrorDev(['Hello', 'Good day', 'Bye']);91 }, 'Received warning unexpectedly does not include a component stack');92 expectToWarnAndToThrow(() => {93 expect(() => {94 console.error('Hello');95 console.error('Good day');96 console.error('Bye');97 }).toErrorDev(['Hello', 'Good day', 'Bye']);98 }, 'Received warning unexpectedly does not include a component stack');99 });100 it('fails if warning is expected to not have a stack, but does', () => {101 expectToWarnAndToThrow(() => {102 expect(() => {103 console.error('Hello\n in div');104 }).toErrorDev('Hello', {withoutStack: true});105 }, 'Received warning unexpectedly includes a component stack');106 expectToWarnAndToThrow(() => {107 expect(() => {108 console.error('Hello\n in div');109 console.error('Good day');110 console.error('Bye\n in div');111 }).toErrorDev(['Hello', 'Good day', 'Bye'], {withoutStack: true});112 }, 'Received warning unexpectedly includes a component stack');113 });114 it('fails if expected stack-less warning number does not match the actual one', () => {115 expectToWarnAndToThrow(() => {116 expect(() => {117 console.error('Hello\n in div');118 console.error('Good day');119 console.error('Bye\n in div');120 }).toErrorDev(['Hello', 'Good day', 'Bye'], {withoutStack: 4});121 }, 'Expected 4 warnings without a component stack but received 1');122 });123 it('fails if withoutStack is invalid', () => {124 expectToWarnAndToThrow(() => {125 expect(() => {126 console.error('Hi');127 }).toErrorDev('Hi', {withoutStack: null});128 }, 'Instead received object');129 expectToWarnAndToThrow(() => {130 expect(() => {131 console.error('Hi');132 }).toErrorDev('Hi', {withoutStack: {}});133 }, 'Instead received object');134 expectToWarnAndToThrow(() => {135 expect(() => {136 console.error('Hi');137 }).toErrorDev('Hi', {withoutStack: 'haha'});138 }, 'Instead received string');139 });140 it('fails if the argument number does not match', () => {141 expectToWarnAndToThrow(() => {142 expect(() => {143 console.error('Hi %s', 'Sara', 'extra');144 }).toErrorDev('Hi', {withoutStack: true});145 }, 'Received 2 arguments for a message with 1 placeholders');146 expectToWarnAndToThrow(() => {147 expect(() => {148 console.error('Hi %s');149 }).toErrorDev('Hi', {withoutStack: true});150 }, 'Received 0 arguments for a message with 1 placeholders');151 });152 it('fails if stack is passed twice', () => {153 expectToWarnAndToThrow(() => {154 expect(() => {155 console.error('Hi %s%s', '\n in div', '\n in div');156 }).toErrorDev('Hi');157 }, 'Received more than one component stack for a warning');158 });159 it('fails if multiple strings are passed without an array wrapper', () => {160 expectToWarnAndToThrow(() => {161 expect(() => {162 console.error('Hi \n in div');163 }).toErrorDev('Hi', 'Bye');164 }, 'toErrorDev() second argument, when present, should be an object');165 expectToWarnAndToThrow(() => {166 expect(() => {167 console.error('Hi \n in div');168 console.error('Bye \n in div');169 }).toErrorDev('Hi', 'Bye');170 }, 'toErrorDev() second argument, when present, should be an object');171 expectToWarnAndToThrow(() => {172 expect(() => {173 console.error('Hi \n in div');174 console.error('Wow \n in div');175 console.error('Bye \n in div');176 }).toErrorDev('Hi', 'Bye');177 }, 'toErrorDev() second argument, when present, should be an object');178 expectToWarnAndToThrow(() => {179 expect(() => {180 console.error('Hi \n in div');181 console.error('Wow \n in div');182 console.error('Bye \n in div');183 }).toErrorDev('Hi', 'Wow', 'Bye');184 }, 'toErrorDev() second argument, when present, should be an object');185 });186 it('fails on more than two arguments', () => {187 expectToWarnAndToThrow(() => {188 expect(() => {189 console.error('Hi \n in div');190 console.error('Wow \n in div');191 console.error('Bye \n in div');192 }).toErrorDev('Hi', undefined, 'Bye');193 }, 'toErrorDev() received more than two arguments.');194 });195 }196});197describe('toWarnDev', () => {198 it('does not fail if a warning contains a stack', () => {199 expect(() => {200 if (__DEV__) {201 console.warn('Hello\n in div');202 }203 }).toWarnDev('Hello');204 });205 it('does not fail if all warnings contain a stack', () => {206 expect(() => {207 if (__DEV__) {208 console.warn('Hello\n in div');209 console.warn('Good day\n in div');210 console.warn('Bye\n in div');211 }212 }).toWarnDev(['Hello', 'Good day', 'Bye']);213 });214 it('does not fail if warnings without stack explicitly opt out', () => {215 expect(() => {216 if (__DEV__) {217 console.warn('Hello');218 }219 }).toWarnDev('Hello', {withoutStack: true});220 expect(() => {221 if (__DEV__) {222 console.warn('Hello');223 console.warn('Good day');224 console.warn('Bye');225 }226 }).toWarnDev(['Hello', 'Good day', 'Bye'], {withoutStack: true});227 });228 it('does not fail when expected stack-less warning number matches the actual one', () => {229 expect(() => {230 if (__DEV__) {231 console.warn('Hello\n in div');232 console.warn('Good day');233 console.warn('Bye\n in div');234 }235 }).toWarnDev(['Hello', 'Good day', 'Bye'], {withoutStack: 1});236 });237 if (__DEV__) {238 // Helper methods avoids invalid toWarn().toThrow() nesting239 // See no-to-warn-dev-within-to-throw240 const expectToWarnAndToThrow = (expectBlock, expectedErrorMessage) => {241 let caughtError;242 try {243 expectBlock();244 } catch (error) {245 caughtError = error;246 }247 expect(caughtError).toBeDefined();248 expect(caughtError.message).toContain(expectedErrorMessage);249 };250 it('fails if a warning does not contain a stack', () => {251 expectToWarnAndToThrow(() => {252 expect(() => {253 console.warn('Hello');254 }).toWarnDev('Hello');255 }, 'Received warning unexpectedly does not include a component stack');256 });257 it('fails if some warnings do not contain a stack', () => {258 expectToWarnAndToThrow(() => {259 expect(() => {260 console.warn('Hello\n in div');261 console.warn('Good day\n in div');262 console.warn('Bye');263 }).toWarnDev(['Hello', 'Good day', 'Bye']);264 }, 'Received warning unexpectedly does not include a component stack');265 expectToWarnAndToThrow(() => {266 expect(() => {267 console.warn('Hello');268 console.warn('Good day\n in div');269 console.warn('Bye\n in div');270 }).toWarnDev(['Hello', 'Good day', 'Bye']);271 }, 'Received warning unexpectedly does not include a component stack');272 expectToWarnAndToThrow(() => {273 expect(() => {274 console.warn('Hello\n in div');275 console.warn('Good day');276 console.warn('Bye\n in div');277 }).toWarnDev(['Hello', 'Good day', 'Bye']);278 }, 'Received warning unexpectedly does not include a component stack');279 expectToWarnAndToThrow(() => {280 expect(() => {281 console.warn('Hello');282 console.warn('Good day');283 console.warn('Bye');284 }).toWarnDev(['Hello', 'Good day', 'Bye']);285 }, 'Received warning unexpectedly does not include a component stack');286 });287 it('fails if warning is expected to not have a stack, but does', () => {288 expectToWarnAndToThrow(() => {289 expect(() => {290 console.warn('Hello\n in div');291 }).toWarnDev('Hello', {withoutStack: true});292 }, 'Received warning unexpectedly includes a component stack');293 expectToWarnAndToThrow(() => {294 expect(() => {295 console.warn('Hello\n in div');296 console.warn('Good day');297 console.warn('Bye\n in div');298 }).toWarnDev(['Hello', 'Good day', 'Bye'], {299 withoutStack: true,300 });301 }, 'Received warning unexpectedly includes a component stack');302 });303 it('fails if expected stack-less warning number does not match the actual one', () => {304 expectToWarnAndToThrow(() => {305 expect(() => {306 console.warn('Hello\n in div');307 console.warn('Good day');308 console.warn('Bye\n in div');309 }).toWarnDev(['Hello', 'Good day', 'Bye'], {310 withoutStack: 4,311 });312 }, 'Expected 4 warnings without a component stack but received 1');313 });314 it('fails if withoutStack is invalid', () => {315 expectToWarnAndToThrow(() => {316 expect(() => {317 console.warn('Hi');318 }).toWarnDev('Hi', {withoutStack: null});319 }, 'Instead received object');320 expectToWarnAndToThrow(() => {321 expect(() => {322 console.warn('Hi');323 }).toWarnDev('Hi', {withoutStack: {}});324 }, 'Instead received object');325 expectToWarnAndToThrow(() => {326 expect(() => {327 console.warn('Hi');328 }).toWarnDev('Hi', {withoutStack: 'haha'});329 }, 'Instead received string');330 });331 it('fails if the argument number does not match', () => {332 expectToWarnAndToThrow(() => {333 expect(() => {334 console.warn('Hi %s', 'Sara', 'extra');335 }).toWarnDev('Hi', {withoutStack: true});336 }, 'Received 2 arguments for a message with 1 placeholders');337 expectToWarnAndToThrow(() => {338 expect(() => {339 console.warn('Hi %s');340 }).toWarnDev('Hi', {withoutStack: true});341 }, 'Received 0 arguments for a message with 1 placeholders');342 });343 it('fails if stack is passed twice', () => {344 expectToWarnAndToThrow(() => {345 expect(() => {346 console.warn('Hi %s%s', '\n in div', '\n in div');347 }).toWarnDev('Hi');348 }, 'Received more than one component stack for a warning');349 });350 it('fails if multiple strings are passed without an array wrapper', () => {351 expectToWarnAndToThrow(() => {352 expect(() => {353 console.warn('Hi \n in div');354 }).toWarnDev('Hi', 'Bye');355 }, 'toWarnDev() second argument, when present, should be an object');356 expectToWarnAndToThrow(() => {357 expect(() => {358 console.warn('Hi \n in div');359 console.warn('Bye \n in div');360 }).toWarnDev('Hi', 'Bye');361 }, 'toWarnDev() second argument, when present, should be an object');362 expectToWarnAndToThrow(() => {363 expect(() => {364 console.warn('Hi \n in div');365 console.warn('Wow \n in div');366 console.warn('Bye \n in div');367 }).toWarnDev('Hi', 'Bye');368 }, 'toWarnDev() second argument, when present, should be an object');369 expectToWarnAndToThrow(() => {370 expect(() => {371 console.warn('Hi \n in div');372 console.warn('Wow \n in div');373 console.warn('Bye \n in div');374 }).toWarnDev('Hi', 'Wow', 'Bye');375 }, 'toWarnDev() second argument, when present, should be an object');376 });377 it('fails on more than two arguments', () => {378 expectToWarnAndToThrow(() => {379 expect(() => {380 console.warn('Hi \n in div');381 console.warn('Wow \n in div');382 console.warn('Bye \n in div');383 }).toWarnDev('Hi', undefined, 'Bye');384 }, 'toWarnDev() received more than two arguments.');385 });386 }...
seed.py
Source:seed.py
1db.session.create_all()2 3player1= Players(player_id=2434, name='Christian McCaffrey', position='RB', team='CAR', adp=1.2, high=1, low=4, stdev=0.5,bye=13)4player2= Players(player_id=2432, name= 'Dalvin Cook', position= 'RB', team= 'MIN', adp= 2.6, high= 1, low= 5, stdev= 0.7, bye= 7)5player3= Players(player_id=2350, name= 'Derrick Henry', position= 'RB', team= 'TEN', adp= 4.1, high= 1, low= 8, stdev= 1.3, bye= 13)6player4= Players(player_id=2860, name= 'Saquon Barkley', position= 'RB', team= 'NYG', adp= 4.2, high= 1, low= 8, stdev= 1.3, bye= 10)7player5= Players(player_id=2439, name= 'Alvin Kamara', position= 'RB', team= 'NO', adp= 4.5, high= 1, low= 9, stdev= 1.3, bye= 6)8player6= Players(player_id=4864, name= 'Jonathan Taylor', position= 'RB', team= 'IND', adp= 6.7, high= 2, low= 12, stdev= 1.6, bye= 14)9player7=Players(player_id=2343, name= 'Ezekiel Elliott', position= 'RB', team= 'DAL', adp= 7.1, high= 2, low= 15, stdev= 1.7, bye= 7)10player8=Players(player_id=2863, name= 'Nick Chubb', position= 'RB', team= 'CLE', adp= 8.0, high= 3, low= 14, stdev= 1.9, bye= 13)11player9=Players(player_id=2125, name= 'Davante Adams', position= 'WR', team= 'GB', adp= 8.5, high= 1, low= 15, stdev= 2.6, bye= 13)12player10=Players(player_id=1989, name= 'Travis Kelce', position= 'TE', team= 'KC', adp= 9.1, high= 3, low= 16, stdev= 2.1, bye= 12)13player11=Players(player_id=2390, name= 'Tyreek Hill', position= 'WR', team= 'KC', adp= 11.0, high= 5, low= 17, stdev= 2.2, bye= 12)14player12=Players(player_id=2507, name= 'Aaron Jones', position= 'RB', team= 'GB', adp= 11.0, high= 5, low= 19, stdev= 2.1, bye= 13)15player13=Players(player_id=2625, name= 'Austin Ekeler', position= 'RB', team= 'LAC', adp= 11.9, high= 5, low= 19, stdev= 2.4, bye= 7)16player14=Players(player_id=2316, name= 'Stefon Diggs', position= 'WR', team= 'BUF', adp= 13.2, high= 6, low= 19, stdev= 2.5, bye= 7)17player15=Players(player_id= 4881, name= 'Cam Akers', position= 'RB', team= 'LAR', adp= 15.0, high= 7, low= 23, stdev= 2.7, bye= 11)18player16=Players(player_id= 1975, name= 'DeAndre Hopkins', position= 'WR', team= 'ARI', adp= 15.2, high= 8, low= 22, stdev= 2.6, bye= 12)19player17=Players(player_id= 5008, name= 'Antonio Gibson', position= 'RB', team= 'WAS', adp= 16.1, high= 10, low= 22, stdev= 2.3, bye= 9)20player18=Players(player_id= 3239, name= 'D.K. Metcalf', position= 'WR', team= 'SEA', adp= 17.2, high= 9, low= 27, stdev= 3.1, bye= 9)21player19=Players(player_id= 2866, name= 'Calvin Ridley', position= 'WR', team= 'ATL', adp= 19.7, high= 12, low= 29, stdev= 2.7, bye= 6)22player20=Players(player_id= 2499, name= 'George Kittle', position= 'TE', team= 'SF', adp= 20.3, high= 12, low= 29, stdev= 3.2, bye= 6)23player21=Players(player_id= 2322, name= 'Darren Waller', position= 'TE', team= 'LV', adp= 21.1, high= 12, low= 29, stdev= 3.1, bye= 8)24player22=Players(player_id= 2462, name= 'Pat Mahomes', position= 'QB', team= 'KC', adp= 21.1, high= 8, low= 32, stdev= 5.0, bye= 12)25player23=Players(player_id= 4862, name= "D'Andre Swift", position= 'RB', team= 'DET', adp= 21.7, high= 11, low= 32, stdev= 3.9, bye= 9)26player24=Players(player_id= 3247, name= 'A.J. Brown', position= 'WR', team= 'TEN', adp= 22.1, high= 12, low= 32, stdev= 3.5, bye= 13)27player25=Players(player_id= 2438, name= 'Joe Mixon', position= 'RB', team= 'CIN', adp= 23.3, high= 9, low= 36, stdev= 5.2, bye= 10)28player26=Players(player_id= 1992, name= 'Keenan Allen', position= 'WR', team= 'LAC', adp= 24.8, high= 16, low= 34, stdev= 3.3, bye= 7)29player27=Players(player_id= 2357, name= 'Michael Thomas', position= 'WR', team= 'NO', adp= 25.8, high= 16, low= 37, stdev= 3.8, bye= 6)30player28=Players(player_id= 3255, name= 'Josh Jacobs', position= 'RB', team= 'LV', adp= 26.7, high= 14, low= 37, stdev= 4.8, bye= 8)31player29=Players(player_id= 4888, name= 'J.K. Dobbins', position= 'RB', team= 'BAL', adp= 27.0, high= 15, low= 38, stdev= 4.4, bye= 8)32player30=Players(player_id= 4876, name= 'Justin Jefferson', position= 'WR', team= 'MIN', adp= 27.0, high= 18, low= 37, stdev= 3.4, bye= 7)33player31=Players(player_id= 5162, name= 'James Robinson', position= 'RB', team= 'JAX', adp= 27.9, high= 1, low= 49, stdev= 11.0, bye= 7)34player32=Players(player_id= 4889, name= 'Clyde Edwards-Helaire', position= 'RB', team= 'KC', adp= 28.5, high= 17, low= 40, stdev= 4.4, bye= 12)35player33=Players(player_id= 3252, name= 'Miles Sanders', position= 'RB', team= 'PHI', adp= 30.5, high= 20, low= 40, stdev= 3.9, bye= 14)36player34=Players(player_id= 3238, name= 'David Montgomery', position= 'RB', team= 'CHI', adp= 31.8, high= 20, low= 42, stdev= 4.2, bye= 10)37player35=Players(player_id= 2130, name= 'Allen Robinson', position= 'WR', team= 'CHI', adp= 34.5, high= 25, low= 47, stdev= 3.6, bye= 10)38player36=Players(player_id= 2518, name= 'Chris Carson', position= 'RB', team= 'SEA', adp= 36.0, high= 27, low= 47, stdev= 3.3, bye= 9)39player37=Players(player_id= 3449, name= 'Terry McLaurin', position= 'WR', team= 'WAS', adp= 36.1, high= 25, low= 46, stdev= 3.9, bye= 9)40player38=Players(player_id= 2885, name= 'Josh Allen', position= 'QB', team= 'BUF', adp= 36.3, high= 22, low= 53, stdev= 5.4, bye= 7)41player39=Players(player_id= 2111, name= 'Mike Evans', position= 'WR', team= 'TB', adp= 37.3, high= 26, low= 51, stdev= 4.0, bye= 9)42player40=Players(player_id= 1796, name= 'Julio Jones', position= 'WR', team= 'ATL', adp= 37.9, high= 26, low= 48, stdev= 4.2, bye= 6)43player41=Players(player_id= 2277, name= 'Amari Cooper', position= 'WR', team= 'DAL', adp= 40.3, high= 28, low= 53, stdev= 4.5, bye= 7)44player42=Players(player_id= 2450, name= 'Kareem Hunt', position= 'RB', team= 'CLE', adp= 40.7, high= 29, low= 51, stdev= 4.1, bye= 13)45player43=Players(player_id= 3299, name= 'Kyler Murray', position= 'QB', team= 'ARI', adp= 41.3, high= 27, low= 58, stdev= 5.4, bye= 12)46player44=Players(player_id= 2465, name= 'Chris Godwin', position= 'WR', team= 'TB', adp= 43.2, high= 33, low= 56, stdev= 3.9, bye= 9)47player45=Players(player_id= 2737, name= 'Raheem Mostert', position= 'RB', team= 'SF', adp= 43.9, high= 30, low= 59, stdev= 5.2, bye= 6)48player46=Players(player_id= 1981, name= 'Robert Woods', position= 'WR', team= 'LAR', adp= 44.3, high= 34, low= 56, stdev= 3.6, bye= 11)49player47=Players(player_id= 4869, name= 'CeeDee Lamb', position= 'WR', team= 'DAL', adp= 44.8, high= 33, low= 59, stdev= 4.2, bye= 7)50player48=Players(player_id= 2872, name= 'Mark Andrews', position= 'TE', team= 'BAL', adp= 45.4, high= 26, low= 61, stdev= 7.3, bye= 8)51player49= Players(player_id= 2431, name= 'Adam Thielen', position= 'WR', team= 'MIN', adp= 46.6, high= 34, low= 61, stdev= 4.6, bye= 7)52player50= Players(player_id=3258, name= 'Myles Gaskin', position='RB', team='MIA', adp=47.6, high=31, low=63, stdev=6.0, bye=14)53db.session.add_all([player1, player2, player3, player4, player5, player6, player7, player8, player9, player10, player11, player12, player13, player14, player15, player16, player17, player18, player19, player20, player21, player22, player23, player24, player25, player26, player27, player28, player29, player30, player31, player32, player33, player34, player35, player36, player37, player38, player39, player40, player41, player42, player43, player44, player45, player46, player47, player48, player49, player50])...
get-parameter-list.spec.js
Source:get-parameter-list.spec.js
1import { getParameterList } from './get-parameter-list.js';2describe('returns an array of strings with the parameter names for a function', () => {3 describe('no parameters', () => {4 it('arrow', () => {5 // the AST representation for an implicit arrow's params is the same6 // no need to test them as well7 const funky = () => {};8 expect(getParameterList(funky)).toEqual([]);9 });10 it('function declaration', () => {11 function funky() {}12 expect(getParameterList(funky)).toEqual([]);13 });14 it('anonymous function expression', () => {15 const funky = function () {};16 expect(getParameterList(funky)).toEqual([]);17 });18 it('named function expression', () => {19 const funky = function funk() {};20 expect(getParameterList(funky)).toEqual([]);21 });22 });23 describe('one parameter', () => {24 it('arrow (with parens)', () => {25 // prettier-ignore26 const funky = (hi) => {};27 expect(getParameterList(funky)).toEqual(['hi']);28 });29 it('arrow (without parens)', () => {30 // prettier-ignore31 const funky = hi => {};32 expect(getParameterList(funky)).toEqual(['hi']);33 });34 it('function declaration', () => {35 function funky(hi) {}36 expect(getParameterList(funky)).toEqual(['hi']);37 });38 it('anonymous function expression', () => {39 const funky = function (hi) {};40 expect(getParameterList(funky)).toEqual(['hi']);41 });42 it('named function expression', () => {43 const funky = function funk(hi) {};44 expect(getParameterList(funky)).toEqual(['hi']);45 });46 });47 describe('multiple parameters', () => {48 it('arrow', () => {49 const funky = (hi, bye, chai) => {};50 expect(getParameterList(funky)).toEqual(['hi', 'bye', 'chai']);51 });52 it('function declaration', () => {53 function funky(hi, bye, chai) {}54 expect(getParameterList(funky)).toEqual(['hi', 'bye', 'chai']);55 });56 it('anonymous function expression', () => {57 const funky = function (hi, bye, chai) {};58 expect(getParameterList(funky)).toEqual(['hi', 'bye', 'chai']);59 });60 it('named function expression', () => {61 const funky = function funk(hi, bye, chai) {};62 expect(getParameterList(funky)).toEqual(['hi', 'bye', 'chai']);63 });64 });65 describe('rest parameters', () => {66 it('arrow', () => {67 const funky = (hi, bye, ...chai) => {};68 expect(getParameterList(funky)).toEqual(['hi', 'bye', 'chai']);69 });70 it('function declaration', () => {71 function funky(hi, bye, ...chai) {}72 expect(getParameterList(funky)).toEqual(['hi', 'bye', 'chai']);73 });74 it('anonymous function expression', () => {75 const funky = function (hi, bye, ...chai) {};76 expect(getParameterList(funky)).toEqual(['hi', 'bye', 'chai']);77 });78 it('named function expression', () => {79 const funky = function funk(hi, bye, ...chai) {};80 expect(getParameterList(funky)).toEqual(['hi', 'bye', 'chai']);81 });82 });83 describe('default parameters', () => {84 it('arrow', () => {85 const funky = (hi = 1, bye = '') => {};86 expect(getParameterList(funky)).toEqual(['hi', 'bye']);87 });88 it('function declaration', () => {89 function funky(hi = 1, bye = '') {}90 expect(getParameterList(funky)).toEqual(['hi', 'bye']);91 });92 it('anonymous function expression', () => {93 const funky = function (hi = 1, bye = '') {};94 expect(getParameterList(funky)).toEqual(['hi', 'bye']);95 });96 it('named function expression', () => {97 const funky = function funk(hi = 1, bye = '') {};98 expect(getParameterList(funky)).toEqual(['hi', 'bye']);99 });100 });101 describe('destructured parameters', () => {102 it('arrow', () => {103 const funky = ({ hi, bye }) => {};104 expect(getParameterList(funky)).toEqual(['hi', 'bye']);105 });106 it('function declaration', () => {107 function funky({ hi, bye }) {}108 expect(getParameterList(funky)).toEqual(['hi', 'bye']);109 });110 it('anonymous function expression', () => {111 const funky = function ({ hi, bye }) {};112 expect(getParameterList(funky)).toEqual(['hi', 'bye']);113 });114 it('named function expression', () => {115 const funky = function funk({ hi, bye }) {};116 expect(getParameterList(funky)).toEqual(['hi', 'bye']);117 });118 });119 describe('destructured parameters with defaults', () => {120 it('arrow', () => {121 const funky = ({ hi = 1, bye = '' }) => {};122 expect(getParameterList(funky)).toEqual(['hi', 'bye']);123 });124 it('function declaration', () => {125 function funky({ hi = 1, bye = '' }) {}126 expect(getParameterList(funky)).toEqual(['hi', 'bye']);127 });128 it('anonymous function expression', () => {129 const funky = function ({ hi = 1, bye = '' }) {};130 expect(getParameterList(funky)).toEqual(['hi', 'bye']);131 });132 it('named function expression', () => {133 const funky = function funk({ hi = 1, bye = '' }) {};134 expect(getParameterList(funky)).toEqual(['hi', 'bye']);135 });136 });137 describe('disasters', () => {138 it('arrow', () => {139 const funky = (a, { b, c = '' }, d = 3 + 2, ...e) => {};140 expect(getParameterList(funky)).toEqual(['a', 'b', 'c', 'd', 'e']);141 });142 it('function declaration', () => {143 function funky(a, { b, c = '' }, d = 3 + 2, ...e) {}144 expect(getParameterList(funky)).toEqual(['a', 'b', 'c', 'd', 'e']);145 });146 it('anonymous function expression', () => {147 const funky = function (a, { b, c = '' }, d = 3 + 2, ...e) {};148 expect(getParameterList(funky)).toEqual(['a', 'b', 'c', 'd', 'e']);149 });150 it('named function expression', () => {151 const funky = function funk(a, { b, c = '' }, d = 3 + 2, ...e) {};152 expect(getParameterList(funky)).toEqual(['a', 'b', 'c', 'd', 'e']);153 });154 });...
utils.py
Source:utils.py
1import pyshorteners # https://pyshorteners.readthedocs.io/en/latest/2import json3import datetime4import calendar5import pandas as pd6from config import *7###########################################################8# TOOLS9###########################################################10def next_day(cal_day=calendar.SATURDAY):11 today = datetime.date.today() #reference point.12 day = today + datetime.timedelta((cal_day-today.weekday()) % 7 )13 return day14def print_json_pretty(data_json):15 print(json.dumps(data_json, sort_keys=True, indent=4))16# TinyURL shortener service17def shorten_url(url):18 s = pyshorteners.Shortener()19 try:20 return s.tinyurl.short(url)21 except:22 return s.dagd.short(url)23###########################################################24# TEAM APP TOOLS25###########################################################26DESC_TAPP_DEFAULT = """27Opponent: {opponent}28Venue: {venue} {court}29Address: {address} {address_tips}30Google Maps coord: https://maps.google.com/?q={coord}31Check the game in PlayHQ: {url_game}32Check the round in PlayHQ: {url_grade}33"""34TAPP_COLS_CSV = ['event_name', 'team_name', 'start_date', 'end_date', 'start_time', 'end_time', 'description', 'venue', 'location', 'access_groups', 'rsvp', 'comments', 'attendance_tracking', 'duty_roster', 'ticketing']35def to_teamsapp_schedule(games_df : pd.DataFrame, desc_template=DESC_TAPP_DEFAULT, game_duration=45):36 """Translates a game fixture table from PlayHQ data to the format used in TeamApp for CSV Schedule import37 Args:38 games_df (pd.DataFrame): a table of games39 desc_template (str, optional): Text to use in the TeamApp description field of each game40 Returns:41 pd.DataFrame: a dataframe representing CSV file for import into TeamApp Schedule42 """43 # fields used by TeamApp44 TAPP_COLS_CSV = ['event_name', 'team_name', 'start_date', 'end_date', 'start_time', 'end_time', 'description', 'venue', 'location', 'access_groups', 'rsvp', 'comments', 'attendance_tracking', 'duty_roster', 'ticketing'] + ['opponent', 'court']45 def extract_opponent(team_id, competitors):46 if competitors[0]['id'] != team_id:47 return competitors[0]['name']48 else:49 return competitors[1]['name']50 games_tapps_df = games_df.loc[:, ['team_name', 'team_id', 'round_name', 'round_abbreviatedName']]51 games_tapps_df['event_name'] = games_tapps_df['team_name'] + " - " + games_tapps_df['round_name']52 games_tapps_df['opponent'] = games_df.apply(lambda x: extract_opponent(x['team_id'], x['competitors']), axis=1)53 games_tapps_df['schedule_timestamp'] = games_df['schedule_timestamp']54 games_tapps_df['start_date'] = games_df['schedule_timestamp'].dt.date55 games_tapps_df['end_date'] = games_tapps_df['start_date']56 # # team_apps_df['start_time'] = pd.to_datetime(club_upcoming_games_df['schedule.time'], format="%H:%M:%S").dt.time57 games_tapps_df['start_time'] = games_df['schedule_timestamp'].dt.time58 games_tapps_df['end_time'] = (games_df['schedule_timestamp'] + datetime.timedelta(minutes=game_duration)).dt.time59 games_tapps_df['location'] = games_df['venue_address_line1'] + ", " + games_df['venue_address_suburb']60 # team_apps_df['location'] = club_upcoming_games_df[['venue.address.line1', 'venue.address.suburb']].agg(','.join, axis=1)61 games_tapps_df['access_groups'] = games_tapps_df['team_name']62 games_tapps_df['rsvp'] = 163 games_tapps_df['comments'] = 164 games_tapps_df['attendance_tracking'] = 065 games_tapps_df['duty_roster'] = 166 games_tapps_df['ticketing'] = 067 games_tapps_df['reference_id'] = ""68 games_tapps_df['venue'] = games_df['venue_name']69 games_tapps_df['court'] = games_df['venue_surfaceName']70 games_tapps_df['geo'] = "(" + games_df['venue_address_latitude'].astype(str) + "," + games_df['venue_address_longitude'].astype(str) + ")"71 games_tapps_df['game_url'] = games_df.apply(lambda x : shorten_url(x['url']), axis=1)72 games_tapps_df['grade_url'] = games_df.apply(lambda x : shorten_url(x['grade_url']), axis=1)73 games_tapps_df['description'] = games_tapps_df.apply(lambda x: desc_template.format(74 opponent=x['opponent'],75 venue=x['venue'],76 court=x['court'],77 address=x['location'],78 address_tips='',79 coord=x['geo'],80 url_game=x['game_url'],81 url_grade=x['grade_url']), axis=182 )83 # return the dataframe with just the columns that TeamApp uses for CSV import84 games_tapps_df = games_tapps_df.loc[:, TAPP_COLS_CSV]85 return games_tapps_df86def build_teamsapp_bye_schedule(teams: list, date: datetime):87 if teams is None or len(teams) == 0: # there are BYE games88 return None89 bye_teams_df = pd.DataFrame(teams, columns =['team_name'])90 # bye_teams_df['team_name'] = bye_teams_df.apply(lambda x: re.search("U.*", x['name']).group(0), axis=1)91 bye_teams_df['access_groups'] = bye_teams_df['team_name']92 bye_teams_df['event_name'] = bye_teams_df['team_name'] + " - BYE"93 bye_teams_df['start_date'] = date94 bye_teams_df['end_date'] = date95 bye_teams_df['start_time'] = datetime.time(hour=0,minute=0,second=0)96 bye_teams_df['end_time'] = datetime.time(hour=0,minute=0,second=0)97 bye_teams_df['description'] = DESC_BYE_TAPP98 bye_teams_df['location'] = ""99 bye_teams_df['venue'] = "BYE"100 bye_teams_df['rsvp'] = 0101 bye_teams_df['comments'] = 0102 bye_teams_df['attendance_tracking'] = 0103 bye_teams_df['duty_roster'] = 0104 bye_teams_df['ticketing'] = 0105 bye_teams_df['reference_id'] = ""106 bye_teams_df = bye_teams_df[TAPP_COLS_CSV]...
data_struc.py
Source:data_struc.py
1# data structure2message = "hello hi"3# every item/ data in variable is stroed as index. 4# index value: 5print(message[1])6# it's a bit difficult so we use data structure 7# list8# each item in the list is stored as index vaue. 9message = ['hello', 'hi', 'bye']10print(message[0:3])11# note that you need square brackets for the list and when you're writing print. 12# also note that you need to write one index value greater to get the value. 13# append-- it just adds a value at the end of it. 14message = ['hello', 'hi', 'bye']15message.append("hey")16print(message)17# insert-- you can add a value in the middle of list18message = ['hello', 'hi', 'bye']19message.insert(0, "hey")20print(message)21# what if we have 2 lists and we want to add the content of the new list to the first list.22message = ['hello', 'hi', 'bye']23greeting = ['hey', 'bye']24message.extend(greeting)25print(message)26# you can also remove an item27message = ['hello', 'hi', 'bye']28greeting = ['hey', 'bye']29message.extend(greeting)30message.remove('hi')31print(message)32# pop33message = ['hello', 'hi', 'bye']34message.pop('hi')35print(message)36# it will give you an error. You need to write an int in the pop function.37# pop remembers what it removed. 38message.pop(0)39removed = message.pop(1)40print(message)41print(removed)42# in operator-- it helps you to find if the item is present in the list or not.43message = ['hello', 'hi', 'bye']44print("hi" in message) 45# it will give you boolian value. 46# for loop47message = ['hello', 'hi', 'bye']48for i in message:49 print(i)50# how does the for loop work?51# i goes to the index 0 which is present in message- value is true52# Then it print that i. 53# i then goes to index 1 ('hi'), it is present in the message. True statment. 54# Then it print that i again. 55# It does it until it gets a false value.56if True:57 print("the statement was True")58# Now what if we want to find the value of index also. 59# To do this we use a function called enumerate. 60greeting = ['hello', 'hi', 'bye']61for message in enumerate(greeting):62 print(message)63# or 64greeting = ['hello', 'hi', 'bye']65for index, message in enumerate(greeting):66 print(index, message)67# message is just i. 68# remember that you need to add the colon at the end.69# Now what if we want to convert this list into string. How do we do this?70# we use the function called .join and join it with string71greeting = ['hello', 'hi', 'bye']72greeting_str = ' - '.join(greeting)73print(greeting_str)74# # Now if we want to convert the string into list, we use split operator.75greeting_str = greeting_str.split(' ')76print((greeting_str))77# tupple = immutable 78tupple_1 = ('hello', 'hi', 'bye')79tupple_2 = (tupple_1)80print(tupple_1)81print(tupple_2)82tupple_1[0] = 'hey'83print(tupple_1)84print(tupple_2)85# it's giving an error because they are immutable and it does not support item assignment. 86# Sets. it will only write the unique items. write inside the curly item87# sets = {'hello', 'hi', 'bye', 'hey', 'bye', 'Hello'}88# print (sets)89# to find the if something is present in a set. 90# sets = {'hello', 'hi', 'bye', 'hey', 'bye', 'Hello'}...
hu.py
Source:hu.py
1from chatterbot.trainers import ListTrainer2from chatterbot import ChatBot3from tkinter import *4import os5import win32com.client as Bolna678Vaachal = Bolna.Dispatch('SAPI.SpVoice')910Batuni = ChatBot('Test')11Batuni.set_trainer(ListTrainer)1213for Text_Files in os.listdir('yo'):14 Baat_Cheet = open('yo/' + Text_Files,'r').readlines()15 Batuni.train(Baat_Cheet)161718#Vaachal.Speak('Hello! I am Batuni .... the chatbot. I would love to chat with you')1920def Bolte_Raho(SunLo):21 while True:22 request = SunLo23 if request == 'bye':24 Vaachal.Speak('chat shall now terminate ... GoodBye!')25 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'26 return Vaapis27 break28 29 if request == 'Bye':30 Vaachal.Speak('chat shall now terminate ... GoodBye!')31 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'32 return Vaapis33 break34 35 if request == 'Exit':36 Vaachal.Speak('chat shall now terminate ... GoodBye!')37 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'38 return Vaapis39 break40 41 if request == 'exit':42 Vaachal.Speak('chat shall now terminate ... GoodBye!')43 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'44 return Vaapis45 break46 47 if request == 'terminate':48 Vaachal.Speak('chat shall now terminate ... GoodBye!')49 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'50 return Vaapis51 break52 53 if request == 'terminate':54 Vaachal.Speak('chat shall now terminate ... GoodBye!')55 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'56 return Vaapis57 break58 59 if request == 'GoodBye':60 Vaachal.Speak('chat shall now terminate ... GoodBye!')61 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'62 return Vaapis63 break64 65 if request == 'goodbye':66 Vaachal.Speak('chat shall now terminate ... GoodBye!')67 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'68 break69 70 if request == 'Good Bye':71 Vaachal.Speak('chat shall now terminate ... GoodBye!')72 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'73 return Vaapis74 break75 76 if request == 'good bye':77 Vaachal.Speak('chat shall now terminate ... GoodBye!')78 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'79 return Vaapis80 break81 82 if request == 'Stop Chat':83 Vaachal.Speak('chat shall now terminate ... GoodBye!')84 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'85 return Vaapis86 break87 88 if request == 'stop chat':89 Vaachal.Speak('chat shall now terminate ... GoodBye!')90 Vaapis = 'Batuni: ' + 'chat shall now terminate ... GoodBye!'91 return Vaapis92 break93 94 response = Batuni.get_response(request)95 Vaachal.Speak(response)96 Vaapis = 'Batuni: ' + response.text
...
textInputTest.py
Source:textInputTest.py
1from tkinter import *2def onclick():3 pass4root = Tk()5text = Text(root)6text.insert(INSERT, "Hello.....")7text.insert(END, "Bye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfgBye Bye....asfasdfsdfg.")8text.pack()9text.tag_add("here", "1.0", "2.4")10text.tag_add("start", "1.8", "1.13")11text.tag_config("here", background="yellow", foreground="blue")12text.tag_config("start", background="black", foreground="green")...
Using AI Code Generation
1var wptraining = require('wptraining');2wptraining.bye();3var wptraining = require('wptraining');4wptraining.hello();5var wptraining = require('wptraining');6wptraining.bye();7var wptraining = require('wptraining');8wptraining.hello();9var wptraining = require('wptraining');10wptraining.bye();11var wptraining = require('wptraining');12wptraining.hello();13var wptraining = require('wptraining');14wptraining.bye();15var wptraining = require('wptraining');16wptraining.hello();17var wptraining = require('wptraining');18wptraining.bye();19var wptraining = require('wptraining');20wptraining.hello();21var wptraining = require('wptraining');22wptraining.bye();23var wptraining = require('wptraining');24wptraining.hello();25var wptraining = require('wptraining');26wptraining.bye();27var wptraining = require('wptraining');28wptraining.hello();
Using AI Code Generation
1var wptest = require('wptest');2wptest.bye();3var wptest = require('./wptest');4wptest.bye();5var wptest = require('./wptest.js');6wptest.bye();7var wptest = require('./wptest.json');8wptest.bye();9var wptest = require('./wptest.node');10wptest.bye();11var wptest = require('wptest.js');12wptest.bye();13var wptest = require('wptest.json');14wptest.bye();15var wptest = require('wptest.node');16wptest.bye();17var wptest = require('wptest/index.js');18wptest.bye();19var wptest = require('wptest/index.json');20wptest.bye();21var wptest = require('wptest/index.node');22wptest.bye();23var wptest = require('wptest/index');24wptest.bye();25var wptest = require('wptest/index.js');26wptest.bye();27var wptest = require('wptest/index.json');28wptest.bye();29var wptest = require('wptest/index.node');30wptest.bye();31var wptest = require('wptest/index');
Using AI Code Generation
1var wpt = require('wpt');2wpt.bye();3module.exports = {4 bye: function() {5 console.log('Bye!');6 }7}
Using AI Code Generation
1var wptest = require('./wptest.js');2wptest.bye();3exports.bye = function() {4 console.log('Bye');5};6var wptest = require('./wptest.js');7wptest.bye();8exports.bye = function() {9 console.log('Bye');10};11You have to export the function from the wptest.js file and then require it in the other file. var wptest = require('./wptest.js'); wptest.bye(); exports.bye = function() { console.log('Bye'); };12exports.bye = function() {13 console.log('Bye');14};15var wptest = require('./wptest.js');16wptest.bye();17var wptest = require('./wptest.js');18wptest.bye();
Using AI Code Generation
1var wp = require('./wptest');2wp.bye();3exports.bye = function(){4 console.log('Bye');5}6var wp = require('./wptest');7wp.bye();8var bye = function(){9 console.log('Bye');10}11exports.bye = bye;12var wp = require('./wptest');13wp();14var bye = function(){15 console.log('Bye');16}17module.exports = bye;18var wp = require('./wptest');19wp();20var bye = function(){21 console.log('Bye');22}23module.exports = bye;24var wp = require('./wptest');25wp();26var bye = function(){27 console.log('Bye');28}29module.exports = bye;30var wp = require('./wptest');31wp();32var bye = function(){33 console.log('Bye');34}35module.exports = bye;36var wp = require('./wptest');37wp();38var bye = function(){39 console.log('Bye');40}41module.exports = bye;
Using AI Code Generation
1var wp = require('./wptest.js');2wp.bye();3wp.hi();4module.exports = {5hello: function() {6console.log('hello');7},8hi: function() {9console.log('hi');10},11bye: function() {12console.log('bye');13}14}15var wp = require('./wptest.js');16wp.bye();17wp.hi();18var wp = function() {19this.hello = function() {20console.log('hello');21},22this.hi = function() {23console.log('hi');24},25this.bye = function() {26console.log('bye');27}28}29module.exports = new wp();30var wp = require('./wptest.js');31wp.bye();32wp.hi();33var wp = function() {34this.hello = function() {35console.log('hello');36},37this.hi = function() {38console.log('hi');39},40this.bye = function() {41console.log('bye');42}43}44module.exports = wp;45var wp = require('./wptest.js');46var obj = new wp();47obj.bye();48obj.hi();49var wp = function() {50this.hello = function() {51console.log('hello');52},53this.hi = function() {54console.log('hi');55},56this.bye = function() {57console.log('
Using AI Code Generation
1var wp = require('./wptest.js');2wp.bye();3var fs = require('fs');4var data = fs.readFileSync('input.txt');5console.log(data.toString());6console.log("Program Ended");7To include the File System module, use the require() method:8var fs = require('fs');9var fs = require('fs');10fs.writeFile('mynewfile1.txt', 'Hello content!', function (err) {11 if (err) throw err;12 console.log('Saved!');13});14The fs.writeFile() method replaces the specified file and content if it exists. If the file does not exist, a new file, containing the specified content, will be created:15var fs = require('fs');16fs.appendFile('mynewfile1.txt', ' This is my text.', function (err) {17 if (err) throw err;18 console.log('Updated!');19});20The fs.appendFile() method appends specified content to a file. If the file does not exist, the file will be created:21var fs = require('fs');22fs.open('mynewfile1.txt', 'r', function(err, fd) {23 if (err) {24 return console.error(err);25 }26 console.log("File opened successfully!");27});28var fs = require('fs');29fs.readFile('mynewfile1.txt', function (err, data) {30 if (err) {31 return console.error(err);32 }33 console.log("Asynchronous read: " + data.toString());34});
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!!