Best Python code snippet using localstack_python
test_jsx_tag.py
Source: test_jsx_tag.py
...20 .replace('>', '>').replace('"', '"').replace(''', "'")21class SetNestedTest(TestCase):22 def test_simple_key(self):23 d = {}24 set_nested(d, 'foo', 3)25 self.assertEqual({'foo': 3}, d)26 def test_one_level(self):27 d = {}28 set_nested(d, 'foo.bar', 3)29 self.assertEqual({'foo': {'bar': 3}}, d)30 def test_two_levels(self):31 d = {}32 set_nested(d, 'foo.bar.baz', 3)33 self.assertEqual({'foo': {'bar': {'baz': 3}}}, d)34 def test_with_existing_stuff(self):35 d = {'one': 1, 'foo': {'baz': 2}}36 set_nested(d, 'foo.bar', 3)37 self.assertEqual({'one': 1, 'foo': {'bar': 3, 'baz': 2}}, d)38 def test_with_existing_object(self):39 """40 If a top level item to be serialized is an object, we shouldn't fail at41 trying to set the lower level item.42 """43 d = {'foo': object()}44 set_nested(d, 'foo.bar', 3)45 self.assertEqual({'foo': {'bar': 3}}, d)46 def test_top_level_item_doesnt_clobber_nested(self):47 # foo.bar has previously been set48 d = {'foo': {'bar': 3}}49 # if we later try to set foo, we shouldn't clobber foo.bar50 set_nested(d, 'foo', object())51 self.assertEqual({'foo': {'bar': 3}}, d)52class JsxTagTest(TestCase):53 def test_loading_tags(self):54 # We can `load` the tag library55 engine = Engine.get_default()56 template_object = engine.from_string("{% load jsx %}")57 result = template_object.render(Context({}))58 self.assertEqual("", result)59 def try_it(self, content, expected_ctx, raw=False, context=None):60 # Assert that if we do a {% jsx %} block with the given content, that we61 # get the standard empty script tag in the output, the data-sha1 attribute62 # has the sha1 digest of the content, and the `data-ctx` is63 # a JSON-encoding of `expected_ctx`.64 # If `raw` is True, use `content` as the entire template content, not just...
properties_tester.py
Source: properties_tester.py
1# Copyright 2004-2008 Roman Yakovenko.2# Distributed under the Boost Software License, Version 1.0. (See3# accompanying file LICENSE_1_0.txt or copy at4# http://www.boost.org/LICENSE_1_0.txt)5import os6import sys7import unittest8import fundamental_tester_base9from pyplusplus.module_builder import call_policies10class tester_t(fundamental_tester_base.fundamental_tester_base_t):11 EXTENSION_NAME = 'properties'12 def __init__( self, *args ):13 fundamental_tester_base.fundamental_tester_base_t.__init__(14 self15 , tester_t.EXTENSION_NAME16 , *args )17 def customize(self, mb ):18 cls = mb.class_( 'properties_tester_t' )19 count = cls.member_function( 'count' )20 set_count = cls.member_function( 'set_count' )21 count.exclude()22 set_count.exclude()23 cls.add_property( "count", count, set_count )24 cls.add_property( "count_ro", count )25 get_nested = cls.member_function( 'get_nested' )26 get_nested.call_policies = call_policies.return_internal_reference()27 set_nested = cls.member_function( 'set_nested' )28 cls.add_property( "nested_", get_nested, set_nested )29 cls.add_property( "nested_ro", get_nested )30 cls = mb.class_( 'properties_finder_tester_t' )31 cls.add_properties( exclude_accessors=True )32 self.assertTrue( 6 == len( cls.properties ) )33 self.assertTrue( cls.name in [pr.name for pr in cls.properties] )34 def run_tests(self, module):35 pt = module.properties_tester_t()36 self.assertTrue( pt.count == 0 )37 pt.count = 2138 self.assertTrue( pt.m_count == 21 )39def create_suite():40 suite = unittest.TestSuite()41 suite.addTest( unittest.makeSuite(tester_t))42 return suite43def run_suite():44 unittest.TextTestRunner(verbosity=2).run( create_suite() )45if __name__ == "__main__":...
cache.py
Source: cache.py
1# -*- coding: utf-8 -*-2def set_nested(data, value, *keys):3 """Assign to a nested dictionary.4 :param dict data: Dictionary to mutate5 :param value: Value to set6 :param list *keys: List of nested keys7 >>> data = {}8 >>> set_nested(data, 'hi', 'k0', 'k1', 'k2')9 >>> data10 {'k0': {'k1': {'k2': 'hi'}}}11 """12 if len(keys) == 1:13 data[keys[0]] = value14 else:15 if keys[0] not in data:16 data[keys[0]] = {}17 set_nested(data[keys[0]], value, *keys[1:])18class Cache(object):19 """Simple container for storing cached data.20 """21 def __init__(self):22 self.data = {}23 @property24 def raw(self):25 return self.data26 def set(self, schema, key, value):27 set_nested(self.data, value, schema, key)28 def get(self, schema, key):29 try:30 return self.data[schema][key]31 except KeyError:32 return None33 def pop(self, schema, key):34 self.data[schema].pop(key, None)35 def clear(self):36 self.__init__()37 def clear_schema(self, schema):38 self.data.pop(schema, None)39 def __nonzero__(self):40 return bool(self.data)41 # Python 3...
Check out the latest blogs from LambdaTest on this topic:
How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.
API (Application Programming Interface) is a set of definitions and protocols for building and integrating applications. It’s occasionally referred to as a contract between an information provider and an information user establishing the content required from the consumer and the content needed by the producer.
The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.
It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?
Anyone who has worked in the software industry for a while can tell you stories about projects that were on the verge of failure. Many initiatives fail even before they reach clients, which is especially disheartening when the failure is fully avoidable.
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!!