Best Python code snippet using localstack_python
test_enumerable.py
Source:test_enumerable.py
...10 BOB1 = dict(name='Bob', size=1)11 BOB2 = dict(name='Bob', size=2)12 SALLY = dict(name='Sally')13 OBJECTS = [BOB1, BOB2, SALLY]14 def test_basic_usage(self):15 """ Should return a dict with objects grouped, in order, by the function. """16 grouped = group_by(lambda obj: obj['name'], self.OBJECTS)17 expected = {'Bob': [self.BOB1, self.BOB2], 'Sally': [self.SALLY]}18 assert grouped == expected19class TestIndexBy:20 """ Test the index_by function. """21 BOB = dict(name='Bob')22 JOE = dict(name='Joe')23 SALLY = dict(name='Sally')24 OBJECTS = [BOB, JOE, SALLY]25 def test_basic_usage(self):26 """ Should return a dict with objects indexed by the result of the function. """27 grouped = index_by(lambda obj: obj['name'], self.OBJECTS)28 expected = {'Bob': self.BOB, 'Joe': self.JOE, 'Sally': self.SALLY}29 assert grouped == expected30class TestEachSlice:31 """ Test the each_slice function. """32 def test_basic_usage(self):33 """ Should yield slices according the the specified size. """34 response = each_slice(3, range(10))35 expected = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]36 assert isinstance(response, types.GeneratorType)37 assert list(response) == expected38class TestAllCombinations:39 """ Test all_combinations. """40 _no_kwargs = [(1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 2, 3)]41 _min_zero = [tuple()] + _no_kwargs42 EXPECTED = dict(43 no_kwargs=_no_kwargs,44 min_2=[(1, 2), (1, 3), (2, 3), (1, 2, 3)],45 min_zero=_min_zero,46 lt_zero=_min_zero,...
test_atomic_helper.py
Source:test_atomic_helper.py
...4import stat5from cloudinit import atomic_helper6from . import helpers7class TestAtomicHelper(helpers.TempDirTestCase):8 def test_basic_usage(self):9 """write_file takes bytes if no omode."""10 path = self.tmp_path("test_basic_usage")11 contents = b"Hey there\n"12 atomic_helper.write_file(path, contents)13 self.check_file(path, contents)14 def test_string(self):15 """write_file can take a string with mode w."""16 path = self.tmp_path("test_string")17 contents = "Hey there\n"18 atomic_helper.write_file(path, contents, omode="w")19 self.check_file(path, contents, omode="r")20 def test_file_permissions(self):21 """write_file with mode 400 works correctly."""22 path = self.tmp_path("test_file_permissions")...
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!!