Best Python code snippet using slash
contact_listener.py
Source:contact_listener.py
1# -*- encoding: utf-8 -*-2# pilas engine: un motor para hacer videojuegos3#4# Copyright 2010-2014 - Hugo Ruscitti5# License: LGPLv3 (see http://www.gnu.org/licenses/lgpl.html)6#7# Website - http://www.pilas-engine.com.ar8import Box2D as box2d9class ObjetosContactListener(box2d.b2ContactListener):10 """Gestiona las colisiones de los objetos para ejecutar funcionés."""11 def __init__(self, pilas):12 box2d.b2ContactListener.__init__(self)13 self.pilas = pilas14 def BeginContact(self, *args, **kwargs):15 fixture_1 = args[0].fixtureA16 fixture_2 = args[0].fixtureB17 self.detener_figuras_estaticas(args[0])18 self.pilas.colisiones.notificar_colision(fixture_1, fixture_2)19 def EndContact(self, *args, **kwargs):20 # TODO: informar el fin de la colisión.21 self.detener_figuras_estaticas(args[0])22 def PreSolve(self, contact, old):23 fixture_1 = contact.fixtureA24 fixture_2 = contact.fixtureB25 self.detener_figuras_estaticas(contact)26 # Hace que las figuras marcadas como sensores no generen27 # una respuesta de colisión fÃsica (solamente programada).28 if fixture_1.userData['sensor'] or fixture_2.userData['sensor']:29 contact.enabled = False30 def PostSolve(self, contact, old):31 self.detener_figuras_estaticas(contact)32 def detener_figuras_estaticas(self, contact):33 fixture_1 = contact.fixtureA34 fixture_2 = contact.fixtureB35 def detener(body):36 body.linearVelocity = (0, 0)37 body.angularVelocity = 038 if not fixture_1.userData['dinamica']:39 detener(fixture_1.body)40 if not fixture_2.userData['dinamica']:...
test_sample.py
Source:test_sample.py
...5@fixture6def fixture_1():7 return [1, 2, 3, 4, 5, 6, 7]8@fixture9def fixture_2():10 return {1: 2}11def test_answer(fixture_1):12 for items in fixture_1:13 if items == 1:14 assert func(items) == 215 elif items == 2:16 assert func(items) == 317 elif items == 3:18 assert func(items) == 419 elif items == 4:20 assert func(items) == 521 elif items == 5:22 assert func(items) == 623 elif items == 6:...
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!!