Best Python code snippet using lemoncheesecake
test_left_join.py
Source:test_left_join.py
1import pytest2from .left_join import join3class TestLeftJoin:4 def test_proof_of_life(self):5 assert join6 @pytest.fixture7 def ht_1(self):8 ht_1 = {9 'test_1': 'synonym test_1',10 'test_2': 'synonym test_2',11 'test_3': 'synonym test_3',12 'test_4': 'synonym test_4',13 'test_5': 'synonym test_5',14 'test_6': 'synonym test_6',15 }16 return ht_117 @pytest.fixture18 def ht_2(self):19 ht_2 = {20 'test_2': 'antonym test_2',21 'test_3': 'antonym test_3',22 'test_6': 'antonym test_6',23 'test_7': 'antonym test_7',24 'test_8': 'antonym test_8',25 'test_9': 'antonym test_9',26 }27 return ht_228 def test_left_join_pass(self, ht_1, ht_2):29 expected = {30 'test_1': ('synonym test_1', None),31 'test_2': ('synonym test_2', 'antonym test_2'),32 'test_3': ('synonym test_3', 'antonym test_3'),33 'test_4': ('synonym test_4', None),34 'test_5': ('synonym test_5', None),35 'test_6': ('synonym test_6', 'antonym test_6'),36 }37 assert join(ht_1, ht_2) == expected38 def test_left_join_no_matches(self, ht_1):39 ht_2 = {40 'test_7': 'antonym test_7',41 'test_8': 'antonym test_8',42 'test_9': 'antonym test_9',43 }44 expected = {45 'test_1': ('synonym test_1', None),46 'test_2': ('synonym test_2', None),47 'test_3': ('synonym test_3', None),48 'test_4': ('synonym test_4', None),49 'test_5': ('synonym test_5', None),50 'test_6': ('synonym test_6', None),51 }52 assert join(ht_1, ht_2) == expected53 def test_left_join_empty_ht(self):54 ht_1 = ht_2 = {}55 assert join(ht_1, ht_2) == {}56 def test_right_join(self, ht_1, ht_2):57 expected = {58 'test_2': ('antonym test_2', 'synonym test_2'),59 'test_3': ('antonym test_3', 'synonym test_3'),60 'test_6': ('antonym test_6', 'synonym test_6'),61 'test_7': ('antonym test_7', None),62 'test_8': ('antonym test_8', None),63 'test_9': ('antonym test_9', None),64 }...
test_property_notifications.py
Source:test_property_notifications.py
1#------------------------------------------------------------------------------2# Copyright (c) 2005, Enthought, Inc.3# All rights reserved.4#5# This software is provided without warranty under the terms of the BSD6# license included in enthought/LICENSE.txt and may be redistributed only7# under the conditions described in the aforementioned license. The license8# is also available online at http://www.enthought.com/licenses/BSD.txt9# Thanks for using Enthought open source!10#11# Author: David C. Morrill12# Description: <Traits component>13#------------------------------------------------------------------------------14from __future__ import absolute_import15from ..api import HasTraits, Property16class Test(HasTraits):17 __traits__ = {}18 def __value_get(self):19 return self.__dict__.get('_value', 0)20 def __value_set(self, value):21 old_value = self.__dict__.get('_value', 0)22 if value != old_value:23 self._value = value24 self.trait_property_changed('value', old_value, value)25 __traits__['value'] = Property(__value_get, __value_set)26class Test_1 (Test):27 def value_changed(self, value):28 print 'value_changed:', value29class Test_2 (Test):30 def anytrait_changed(self, name, value):31 print 'anytrait_changed for %s: %s' % (name, value)32class Test_3 (Test_2):33 def value_changed(self, value):34 print 'value_changed:', value35def on_value_changed(value):36 print 'on_value_changed:', value37def on_anyvalue_changed(value):38 print 'on_anyvalue_changed:', value39def test_property_notifications():40 Test_1().value = 'test 1'41 Test_2().value = 'test 2'42 Test_3().value = 'test 3'43 test_4 = Test()44 test_4.on_trait_change(on_value_changed, 'value')45 test_4.value = 'test 4'46 test_5 = Test()47 test_5.on_trait_change(on_anyvalue_changed)48 test_5.value = 'test 5'49 test_6 = Test()50 test_6.on_trait_change(on_value_changed, 'value')51 test_6.on_trait_change(on_anyvalue_changed)52 test_6.value = 'test 6'53 test_7 = Test_3()54 test_7.on_trait_change(on_value_changed, 'value')55 test_7.on_trait_change(on_anyvalue_changed)...
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!!