Best Python code snippet using selene_python
testDuplicateFinder.py
Source:testDuplicateFinder.py
...4 def __init__(self, value, hash_code):5 self.hash = hash_code6 self.value = value7class TestDuplicateFinder(unittest.TestCase):8 def find_in(self, nodes):9 nodes = list(Node("%s@%s"%(v, i), v) for i,v in enumerate(nodes + [-1]))10 finder = DuplicateFinder(nodes, [0], collapse_repeat_tokens=0)11 dups = finder.find_start_and_ends()12 dups = list(13 [(nodes[start], nodes[end]) for start, end in v]14 for v in dups)15 return [[(x.value, y.value) for x, y in n] for n in dups]16 def test_no_duplicate(self):17 self.assertEqual([], self.find_in([1,2]))18 def test_simple_duplicate(self):19 self.assertEqual([[("1@0", "1@0"), ("1@1", "1@1")]], self.find_in([1,1]))20 def test_simple_duplicate_3_times(self):21 self.assertIn([("1@0", "1@0"), ("1@1", "1@1"), ("1@2", "1@2")], self.find_in([1,1,1]))22 def test_simple_two_duplicates(self):23 self.assertIn([("1@0", "1@0"), ("1@1", "1@1")], self.find_in([1,1,2,2]))24 self.assertIn([("2@2", "2@2"), ("2@3", "2@3")], self.find_in([1,1,2,2]))25 def test_simple_3_duplicates_in_different_places(self):26 self.assertEqual([[("1@0", "1@0"), ("1@2", "1@2"), ("1@4", "1@4")]], self.find_in([1,2,1,3,1]))27 def test_multiple_nodes_duplicate(self):28 self.assertIn([("1@0", "2@1"), ("1@2", "2@3")], self.find_in([1,2,1,2]))29 self.assertNotIn([("1@0", "1@0"), ("1@2", "1@2")], self.find_in([1,2,1,2]))30 def test_not_multiple_nodes_duplicate(self):31 self.assertIn([("1@0", "1@0"),("1@3", "1@3")], self.find_in([1,3,2,1,2]))32 self.assertIn([("2@2", "2@2"),("2@4", "2@4")], self.find_in([1,3,2,1,2]))33 def test_multiple_nodes_duplicate_and_single_node(self):34 self.assertIn([("1@0", "1@0"), ("1@2", "1@2"), ("1@4", "1@4")], self.find_in([1,2,1,2,1]))35 self.assertIn([("1@0", "2@1"), ("1@2", "2@3")], self.find_in([1,2,1,2,1]))36 def test_3_nodes_duplicate(self):37 self.assertNotIn([("3@2", "3@2"), ("3@5", "3@5")], self.find_in([1,2,3,1,2,3]))38 def test_partial_different_purpose(self):...
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!!