Best Python code snippet using localstack_python
test_default_log_config.py
Source:test_default_log_config.py
1import logging2from unittest import TestCase, main3from expects import expect4from twin_sister import open_dependency_context5from twin_sister.expects_matchers import contain_key_with_value6from questions_three.logging.constants import MESSAGE_FORMAT7from questions_three.scaffolds import disable_default_reporters, enable_default_reporters8from questions_three.scaffolds.xunit import TestSuite9from twin_sister.fakes import EmptyFake, empty_context_manager10class FakeLogging(EmptyFake):11 def __init__(self):12 super().__init__()13 self.config_history = []14 def basicConfig(self, *args, **kwargs):15 self.config_history.append((args, kwargs))16class TestDefaultLogConfig(TestCase):17 def setUp(self):18 disable_default_reporters()19 self.context = open_dependency_context()20 self.context.inject(open, empty_context_manager)21 self.fake_logging = FakeLogging()22 self.context.inject(logging, self.fake_logging)23 def tearDown(self):24 self.context.close()25 enable_default_reporters()26 def test_sets_level_info(self):27 def wrapper():28 class MySuite(TestSuite):29 pass30 wrapper()31 args, kwargs = self.fake_logging.config_history[-1]32 expect(kwargs).to(contain_key_with_value("level", logging.INFO))33 def test_sets_expected_format(self):34 def wrapper():35 class MySuite(TestSuite):36 pass37 wrapper()38 args, kwargs = self.fake_logging.config_history[-1]39 expect(kwargs).to(contain_key_with_value("format", MESSAGE_FORMAT))40if "__main__" == __name__:...
Core.py
Source:Core.py
1#2# Copyright (c) 2017-2018 Joy Diamond. All rights reserved.3#4@gem('Marble.Core')5def gem():6 require_gem('Gem.Ascii')7 require_gem('Gem.ContextManager')8 require_gem('Gem.DelayedFileOutput')9 require_gem('Gem.Exception')10 require_gem('Gem.Path')11 require_gem('Gem.SimpleStringIO')12 require_gem('Gem.System')13 require_gem('Gem.Traceback')14 from Gem import create_DelayedFileOutput, create_SimpleStringOutput, empty_context_manager, execute15 from Gem import lookup_ascii, module_path, path_join, print_exception_chain, program_exit, slice_all16 share(17 #18 # Imported functions19 #20 'create_DelayedFileOutput', create_DelayedFileOutput,21 'create_SimpleStringOutput', create_SimpleStringOutput,22 'empty_context_manager', empty_context_manager,23 'execute', execute,24 'lookup_ascii', lookup_ascii,25 'path_join', path_join,26 'print_exception_chain', print_exception_chain,27 'program_exit', program_exit,28 #29 # Imported values30 #31 'module_path', module_path,32 'slice_all', slice_all,...
test_empty_context_manager.py
Source:test_empty_context_manager.py
...4from twin_sister.fakes import EmptyFake, empty_context_manager5class TestEmptyContextManager(TestCase):6 def test_accepts_arbitrary_args_and_kwargs(self):7 def attempt():8 with empty_context_manager(7, spams=2):9 pass10 expect(attempt).not_to(complain(TypeError))11 def test_yields_an_empty_fake(self):12 with empty_context_manager() as actual:13 expect(actual).to(be_a(EmptyFake))14if "__main__" == __name__:...
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!!