How to use test_expectations method in pyshould

Best Python code snippet using pyshould_python

expectations_parser_test.py

Source:expectations_parser_test.py Github

copy

Full Screen

...434 self.assertEqual(ret, 0)435 test_exp2 = expectations_parser.TestExpectations(['Intel'])436 ret, _ = test_exp2.parse_tagged_list(raw_data2)437 self.assertEqual(ret, 0)438 test_exp1.merge_test_expectations(test_exp2)439 self.assertEqual(sorted(test_exp1.tags), ['intel', 'linux'])440 self.assertEqual(test_exp1.expectations_for('b1/s2'),441 Expectation(442 test='b1/s2',443 results={ResultType.Pass, ResultType.Failure},444 retry_on_failure=True, is_slow_test=False,445 reason='crbug.com/2431 crbug.com/2432',446 trailing_comments=' # c1\n # c2\n',447 tags={'linux', 'intel'}))448 self.assertEqual(test_exp1.expectations_for('b1/s1'),449 Expectation(450 test='b1/s1', results={ResultType.Pass},451 retry_on_failure=True, is_slow_test=False,452 tags={'intel'}))453 self.assertEqual(test_exp1.expectations_for('b1/s3'),454 Expectation(455 test='b1/s3', results={ResultType.Failure},456 retry_on_failure=False, is_slow_test=False,457 tags={'linux'}))458 self.assertEqual(test_exp1.expectations_for('b1/s5'),459 Expectation(460 test='b1/s5', results={ResultType.Failure},461 retry_on_failure=True, is_slow_test=True,462 reason='crbug.com/2431 crbug.com/2432',463 tags={'linux', 'intel'}))464 def testResolutionReturnedFromExpectationsFor(self):465 raw_data1 = (466 '# tags: [ linux ]\n'467 '# results: [ Failure RetryOnFailure Slow ]\n'468 '[ linux ] b1/s3 [ Failure ]\n'469 'crbug.com/2431 [ linux ] b1/s2 [ Failure RetryOnFailure ]\n'470 'crbug.com/2432 [ linux ] b1/s* [ Failure ]\n')471 raw_data2 = (472 '# tags: [ Intel ]\n'473 '# results: [ Pass RetryOnFailure Slow ]\n'474 '[ intel ] b1/s1 [ RetryOnFailure ]\n'475 'crbug.com/2432 [ intel ] b1/s2 [ Pass Slow ]\n'476 'crbug.com/2431 [ intel ] b1/s* [ RetryOnFailure ]\n')477 raw_data3 = (478 '# tags: [ linux ]\n'479 '# results: [ Failure RetryOnFailure Slow ]\n'480 '# conflict_resolution: OVERRIDE\n'481 '[ linux ] b1/s3 [ Failure ]\n'482 'crbug.com/2431 [ linux ] b1/s2 [ Failure RetryOnFailure ]\n'483 'crbug.com/2432 [ linux ] b1/s* [ Failure ]\n')484 test_exp1 = expectations_parser.TestExpectations(['Linux'])485 ret, _ = test_exp1.parse_tagged_list(raw_data1)486 self.assertEqual(ret, 0)487 self.assertEqual(test_exp1.expectations_for('b1/s2'),488 Expectation(489 test='b1/s2', results={ResultType.Failure},490 retry_on_failure=True, is_slow_test=False,491 reason='crbug.com/2431', tags={'linux'},492 conflict_resolution=ConflictResolutionTypes.UNION493 ))494 test_exp2 = expectations_parser.TestExpectations(['Intel'])495 ret, _ = test_exp2.parse_tagged_list(496 raw_data2,497 conflict_resolution = ConflictResolutionTypes.OVERRIDE)498 self.assertEqual(ret, 0)499 self.assertEqual(test_exp2.expectations_for('b1/s2'),500 Expectation(501 test='b1/s2', results={ResultType.Pass},502 retry_on_failure=False, is_slow_test=True,503 reason='crbug.com/2432', tags={'intel'},504 conflict_resolution=ConflictResolutionTypes.OVERRIDE505 ))506 test_exp3 = expectations_parser.TestExpectations(['Linux'])507 ret, _ = test_exp3.parse_tagged_list(raw_data3)508 self.assertEqual(ret, 0)509 self.assertEqual(test_exp3.expectations_for('b1/s2'),510 Expectation(511 test='b1/s2', results={ResultType.Failure},512 retry_on_failure=True, is_slow_test=False,513 reason='crbug.com/2431', tags={'linux'},514 conflict_resolution=ConflictResolutionTypes.OVERRIDE515 ))516 def testMergeExpectationsUsingOverrideResolution(self):517 raw_data1 = (518 '# tags: [ linux ]\n'519 '# results: [ Failure RetryOnFailure Slow ]\n'520 '[ linux ] b1/s3 [ Failure ]\n'521 'crbug.com/2431 [ linux ] b1/s2 [ Failure RetryOnFailure ]\n'522 'crbug.com/2432 [ linux ] b1/s* [ Failure ]\n')523 raw_data2 = (524 '# tags: [ Intel ]\n'525 '# results: [ Pass RetryOnFailure Slow ]\n'526 '[ intel ] b1/s1 [ RetryOnFailure ]\n'527 'crbug.com/2432 [ intel ] b1/s2 [ Pass Slow ]\n'528 'crbug.com/2431 [ intel ] b1/s* [ RetryOnFailure ]\n')529 test_exp1 = expectations_parser.TestExpectations(['Linux'])530 ret, _ = test_exp1.parse_tagged_list(raw_data1)531 self.assertEqual(ret, 0)532 test_exp2 = expectations_parser.TestExpectations(['Intel'])533 ret, _ = test_exp2.parse_tagged_list(534 raw_data2, conflict_resolution=ConflictResolutionTypes.OVERRIDE)535 self.assertEqual(ret, 0)536 test_exp1.merge_test_expectations(test_exp2)537 self.assertEqual(sorted(test_exp1.tags), ['intel', 'linux'])538 self.assertEqual(test_exp1.expectations_for('b1/s2'),539 Expectation(540 test='b1/s2', results={ResultType.Pass},541 retry_on_failure=False, is_slow_test=True,542 reason='crbug.com/2432', tags={'intel'}))543 self.assertEqual(test_exp1.expectations_for('b1/s1'),544 Expectation(test='b1/s1', results={ResultType.Pass},545 retry_on_failure=True, is_slow_test=False,546 tags={'intel'}))547 self.assertEqual(test_exp1.expectations_for('b1/s3'),548 Expectation(test='b1/s3', results={ResultType.Failure},549 retry_on_failure=False, is_slow_test=False,550 tags={'linux'}))...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

1import Marynova_ZBPI211c as mar2import pytest3import math4#TEST 15@pytest.mark.parametrize('n', range(30))6def test_fact(n):7 #Verify the output of `fact` function#8 output = mar.fact(n)9 assert output == math.factorial(n)10#TEST 211import random12 13test_inputs = []14for i in range(30): 15 test_inputs.append(random.sample(range(100), 4))16test_expectations = []17for j in test_inputs:18 test_expectations.append([x for x in j if x % 2 == 0])19EVEN_TEST=list(zip(test_inputs, test_expectations))20@pytest.mark.parametrize("test_lists",EVEN_TEST)21def test_filter_even(test_lists):22 #Verify the output of `filter_even` function23 output = mar.filter_even(test_lists[0])24 assert output == test_lists[1]25#TEST 326test_inputs = []27for i in range(30): 28 test_inputs.append(random.sample(range(100), 4))29test_expectations = []30for j in test_inputs:31 test_expectations.append([x**2 for x in j])32SQUARE_TEST=list(zip(test_inputs, test_expectations))33@pytest.mark.parametrize("test_lists", SQUARE_TEST)34def test_square(test_lists):35 output = mar.square(test_lists[0])36 assert output == test_lists[1] 37#TEST 438list_sample = [x+10 for x in range(30)]39BIN_TEST = []40for i in range(len(list_sample)):41 BIN_TEST.append([list_sample,list_sample[i],i])42@pytest.mark.parametrize("test_lists",BIN_TEST)43def test_bin_search_found(test_lists):44 output = mar.bin_search(test_lists[0],test_lists[1])45 assert output == test_lists[2]46 47def test_bin_search_not_found():48 output = mar.bin_search([2,5,7,9,11,17,222],12)49 assert output == -150 51#TEST 552TEST_PALINDROME = ["Ежу хуже", "Лев осовел", "Зона заноз", "Неуч учуен", "Утоп в поту", "Шику кукиш", "Болвана в лоб", "Да, гневен гад", "Маска как сам", "Чем нежен меч", "Мат и тут и там", "Там холм лохмат", "Вид усов осудив", "Кот, сука, за кусток", "Уверена я, а не реву", "Цени в себе свинец", "Отлично кончил-то", "Кошмар, срам, шок", "Милашка, как шалим", "Нахапал фуфла пахан", "А вот и харя рахитова", "Акт у нимф - минутка", "Аргентина манит негра", "Потенция - яиц нет, оп", "Коту скоро сорок суток", "Лидер Венере не вредил", "Замучен он, но не чумаз", "А леди у ног его - ну и дела", "А роза упала на лапу Азора"]53@pytest.mark.parametrize("test_lists",TEST_PALINDROME)54def test_is_palindrome(test_lists):55 output = mar.is_palindrome(str(test_lists))56 assert output == "YES"57 58def test_is_palindrome_punctuation():59 output = mar.is_palindrome("Madam, I'm Adam")60 assert output == "YES"61 62def test_is_palindrome_case():63 output = mar.is_palindrome("А роза упала на лапу Азора")64 assert output == "YES"65 66def test_is_palindrome_not():67 output = mar.is_palindrome("Some Text That Is not Palindrome")68 assert output == "NO"69 70#TEST 671def test_calculate():72 path_file_input="test_input_file_1.txt"73 path_file_expected="test_output_file_1.txt"74 output = mar.calculate(path_file_input)75 expected = ""76 with open(path_file_expected, mode='r') as f:77 expected = f.read()78 assert output == expected79#TEST 780def test_substring_slice():81 path_file_input_1="test_import_file_2_1.txt"82 path_file_input_2="test_import_file_2_2.txt"83 path_file_expected="test_output_file_2.txt"84 output = mar.substring_slice(path_file_input_1,path_file_input_2)85 expected = ""86 with open(path_file_expected, mode='r') as f:87 expected = f.read()88 assert output == expected89#890def test_decode_ch():91 input_str="NOTiFICaTiON"92 expected_str="АзотКислородТитанФторЙодКальцийТитанКислородАзот"93 output = mar.decode_ch(input_str)94 assert output == expected_str95#996def test_Student():97 tc = mar.Student("Ivan","Ivanov")98 pc = mar.Student("Leha","Levo")99 assert tc.greeting() == "Hello, I am Student"100 assert tc.mean_grade() == 4101 assert tc.is_otlichnik() == "NO"102 assert str(tc) == "Ivan Ivanov"103 assert tc + pc == "Ivan is friends with Leha"104#10105def get_MyError(name):106 if name!="Bikini":107 raise mar.MyError("So full of youth!")108 else:109 return "Username is properly set."110def test_username_MyError():111 """test for invalid username"""112 with pytest.raises(mar.MyError) as e:113 get_MyError("Nick") 114 assert "So full of youth!" in str(e)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyshould automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful