Best Python code snippet using pyshould_python
test_nesting_tokeniser.py
Source: test_nesting_tokeniser.py
1import pytest2class Examples:3 small_example = [4 """5 describe "This":6 describe "That":7 describe "Meh":pass8 describe "Blah":pass9 describe "Another":pass """,10 """11 class TestThis :pass12 class TestThis_That (TestThis ):pass13 class TestThis_That_Meh (TestThis_That ):pass14 class TestThis_Blah (TestThis ):pass15 class TestAnother :pass16 """,17 ]18 ### SMALL EXAMPLE (WITH PATH FOR BW COMPAT)19 small_example_with_pass = [20 """21 describe "This":pass22 describe "That":pass23 describe "Meh":pass24 describe "Blah":pass25 describe "Another":pass """,26 """27 class TestThis :pass28 class TestThis_That (TestThis ):pass29 class TestThis_That_Meh (TestThis_That ):pass30 class TestThis_Blah (TestThis ):pass31 class TestAnother :pass32 """,33 ]34 big_example = [35 """36 describe "This":37 it 'should':38 if x:39 pass40 else:41 x += 942 describe "That":43 describe "Meh":44 it 'should':45 if y:46 pass47 else:48 pass49 describe "Blah":pass50 describe "Another":51 it 'should':52 if z:53 if u:54 print "hello \55 there"56 else:57 print "no"58 else:59 pass60 """,61 """62 class TestThis :63 def test_should (self ):64 if x :65 pass66 else :67 x +=968 class TestThis_That (TestThis ):pass69 class TestThis_That_Meh (TestThis_That ):70 def test_should (self ):71 if y :72 pass73 else :74 pass75 class TestThis_Blah (TestThis ):pass76 class TestAnother :77 def test_should (self ):78 if z :79 if u :80 print "hello \81 there"82 else :83 print "no"84 else :85 pass86 """,87 ]88def assert_example(example, convert_to_tabs=False):89 __tracebackhide__ = True90 pytest.helpers.assert_example(91 example, convert_to_tabs=convert_to_tabs, with_describe_attrs=False92 )93class Test_Tokeniser_Nesting:94 def test_works_with_space(self):95 assert_example(Examples.small_example)96 def test_works_with_tabs(self):97 assert_example(Examples.small_example, convert_to_tabs=True)98 def test_works_with_space_and_inline_pass(self):99 assert_example(Examples.small_example_with_pass)100 def test_works_with_tabs_and_inline_pass(self):101 assert_example(Examples.small_example_with_pass, convert_to_tabs=True)102 def test_keeps_good_indentation_in_body_with_spaces(self):103 assert_example(Examples.big_example)104 def test_keeps_good_indentation_in_body_with_tabs(self):105 assert_example(Examples.big_example, convert_to_tabs=True)106 def test_names_nested_describes_with_part_of_parents_name(self):107 original = 'describe "a":\n\tdescribe "b":'108 desired = "class TestA :pass\nclass TestA_B (TestA ):"...
test_median.py
Source: test_median.py
...5 ([1, 2], [3, 4], 2.5),6 ([1, 2], [3], 2),7 ([1, 2, 9, 12], [3, 4, 10, 16, 19], 9)8])9def test_should(array_one: Sequence[int], array_two: Sequence[int], expected: float):10 result = median.median_of_merged_lists(array_one, array_two)...
Check out the latest blogs from LambdaTest on this topic:
Hey everyone! We hope you had a great Hacktober. At LambdaTest, we thrive to bring you the best with each update. Our engineering and tech teams work at lightning speed to deliver you a seamless testing experience.
Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.
One of the most important tasks of a software developer is not just writing code fast; it is the ability to find what causes errors and bugs whenever you encounter one and the ability to solve them quickly.
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.
The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.
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!!