Best Python code snippet using lemoncheesecake
issequence_containing_test.py
Source:issequence_containing_test.py  
...9__license__ = "BSD, see License.txt"10class IsSequenceContainingTestBase(object):11    def testMatchesASequenceThatContainsAnElementMatchingTheGivenMatcher(self):12        self.assert_matches(13            "sequence contains 'a'", has_item(equal_to("a")), self._sequence("a", "b", "c")14        )15    def testNoMatchIfSequenceDoesntContainAnElementMatchingTheGivenMatcher(self):16        self.assert_does_not_match(17            "sequence without 'a'", has_item(equal_to("a")), self._sequence("b", "c")18        )19        self.assert_does_not_match("empty", has_item(equal_to("a")), [])20    def testProvidesConvenientShortcutForMatchingWithEqualTo(self):21        self.assert_matches("sequence contains 'a'", has_item("a"), self._sequence("a", "b", "c"))22        self.assert_does_not_match("sequence without 'a'", has_item("a"), self._sequence("b", "c"))23    def testMatchesAnyConformingSequence(self):24        self.assert_matches("quasi-sequence", has_item(1), QuasiSequence())25        self.assert_does_not_match("non-sequence", has_item(1), object())26    def testHasAReadableDescription(self):27        self.assert_description("a sequence containing 'a'", has_item("a"))28    def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):29        self.assert_no_mismatch_description(has_item("a"), self._sequence("a", "b"))30    def testMismatchDescriptionShowsActualArgument(self):31        self.assert_mismatch_description("was <42>", has_item("a"), 42)32    def testDescribeMismatch(self):33        self.assert_describe_mismatch("was <42>", has_item("a"), 42)34class IsConcreteSequenceContaining(MatcherTest, SequenceForm, IsSequenceContainingTestBase):35    pass36class IsGeneratorContaining(MatcherTest, GeneratorForm, IsSequenceContainingTestBase):37    pass38class IsSequenceContainingItemsTestBase(object):39    def testShouldMatchCollectionContainingAllItems(self):40        self.assert_matches(41            "contains all items",42            has_items(equal_to("a"), equal_to("b"), equal_to("c")),43            self._sequence("a", "b", "c"),44        )45    def testProvidesConvenientShortcutForMatchingWithEqualTo(self):46        self.assert_matches(47            "Values automatically wrapped with equal_to",...test_artifactory_api.py
Source:test_artifactory_api.py  
...27    def test_find_subfolders_works(self, mock_get):28        mock_get.return_value = MockResponse(29            self.load_fixture('get_sub_folders.json'), 200)30        sub_folders = self.artifactory_api.find_subfolders('root')31        assert_that(sub_folders, has_item('/ironic-sync'))32        assert_that(sub_folders, has_item('/keysmith'))33        assert_that(sub_folders, has_item('/monthly-python'))34    @mock.patch('requests.get')35    def test_obtain_repository_list(self, mock_get):36        mock_get.return_value = MockResponse(37            self.load_fixture('get_sub_repositories.json'), 200)38        expected_repos = ['internap/ironic-sync', 'internap/keysmith',39                          'internap/monthly-python']40        actual_repositories = self.artifactory_api.get_sub_repositories(41            'local-docker')42        assert_that(actual_repositories, has_item(expected_repos[0]))43        assert_that(actual_repositories, has_item(expected_repos[1]))44        assert_that(actual_repositories, has_item(expected_repos[2]))45    @mock.patch('requests.get')46    def test_obtain_tags_from_repository(self, mock_get):47        mock_get.return_value = MockResponse(48            self.load_fixture('tags_list.json'), 200)49        tags = self.artifactory_api.get_tags('local-docker', 'ironic-sync')50        assert_that(tags, has_item('1.1.222'))51    @mock.patch('requests.get')52    def test_get_ephemeral_tags(self, mock_get):53        mock_get.return_value = MockResponse(54            self.load_fixture('tags_list.json'), 200)55        tags = self.artifactory_api.get_tags('local-docker', 'ironic-sync')56        ephemeral_tags = \57            self.artifactory_api.filter_ephemerals(tags,58                                                   '[0-9]\.[0-9]\.[0-9]*\.[Z]')59        assert_that(ephemeral_tags, has_length(7))60        assert_that(ephemeral_tags,61                    has_item('1.0.229.Zad03d3aea5784e1c99ba12eb831e8152'))62        assert_that(ephemeral_tags, is_not(has_item('1.1.222')))63    @mock.patch('requests.get')64    def test_delete_ephemeral_version(self, mock_get):65        mock_get.side_effect = [66            MockResponse(self.load_fixture('tags_list.json'), 200),67            MockResponse('{}', 202)68        ]69        tags = self.artifactory_api.get_tags('local-docker', 'ironic-sync')70        ephemeral_tags = \71            self.artifactory_api.filter_ephemerals(tags,72                                                   '[0-9]\.[0-9]\.[0-9]*\.[Z]')73        assert_that(74            self.artifactory_api.delete_tag('local-docker', 'ironic-sync',75                                            ephemeral_tags[0]), is_(True))76    def load_fixture(self, filename):...b.py
Source:b.py  
1HAS_ITEM = '*'2def solve(matrix, point_a, point_b):3    if point_a['row'] == point_b['row']:4        if point_a['row'] == len(matrix) - 1:5            matrix[point_a['row'] - 1][point_a['col']] = HAS_ITEM6            matrix[point_b['row'] - 1][point_b['col']] = HAS_ITEM7        else:8            matrix[point_a['row'] + 1][point_a['col']] = HAS_ITEM9            matrix[point_b['row'] + 1][point_b['col']] = HAS_ITEM10    elif point_a['col'] == point_b['col']:11        if point_a['col'] == len(matrix) - 1:12            matrix[point_a['row']][point_a['col'] - 1] = HAS_ITEM13            matrix[point_b['row']][point_b['col'] - 1] = HAS_ITEM14        else:15            matrix[point_a['row']][point_a['col'] + 1] = HAS_ITEM16            matrix[point_b['row']][point_b['col'] + 1] = HAS_ITEM17    else:18        matrix[point_a['row']][point_b['col']] = HAS_ITEM19        matrix[point_b['row']][point_a['col']] = HAS_ITEM20    return matrix21def print_matrix(matrix):22    for r in range(len(matrix)):23        for c in range(len(matrix)):24            if c == len(matrix) - 1:25                print(matrix[r][c])26            else:27                print(matrix[r][c], end='')28cases = int(input())29for case in range(cases):30    n = int(input())31    matrix = [['.' for x in range(n)] for y in range(n)]32    points = []33    for r in range(n):34        row = list(input())35        for c in range(n):36            matrix[r][c] = row[c]37            if matrix[r][c] == HAS_ITEM:38                points.append({'row': r, 'col': c})39    matrix = solve(matrix, points[0], points[1])40    print_matrix(matrix)41# ...*42# ...*43# ....44# ....45# ....46# ....47# ....48# ..**49# ..â.50# ....51# â...52# ....53# *...54# ....55# â...56# ....57# *.*.58# ....59# .......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!!
