How to use exit_status method in yandex-tank

Best Python code snippet using yandex-tank

test_phone_book.py

Source: test_phone_book.py Github

copy

Full Screen

1import contextlib2import subprocess3import os4import pytest5@pytest.fixture6def no_db():7 with contextlib.suppress(Exception):8 os.unlink("directory.db")9def run_cmd(cmd):10 cmd = cmd.split()11 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)12 ret = p.wait()13 return ret, p.stdout.read().decode("ascii").strip()14def test_list_without_db(no_db):15 exit_status, op = run_cmd("./​phone_book list")16 assert exit_status == 117 assert op == "Couldn't open database file: No such file or directory"18def test_search_without_db(no_db):19 exit_status, op = run_cmd("./​phone_book search foo")20 assert exit_status == 121 assert op == "Couldn't open database file: No such file or directory"22def test_delete_without_db(no_db):23 exit_status, op = run_cmd("./​phone_book delete foo")24 assert exit_status == 125 assert op == "Couldn't open database file: No such file or directory"26def test_adding_listing(no_db):27 exit_status, _ = run_cmd("./​phone_book add john 1234567890")28 assert exit_status == 029 exit_status, _ = run_cmd("./​phone_book add jack 0987654321")30 assert exit_status == 031 exit_status, _ = run_cmd("./​phone_book add james 5432167890")32 assert exit_status == 033 exit_status, op = run_cmd("./​phone_book list")34 assert exit_status == 035 expected = """john : 123456789036jack : 098765432137james : 543216789038Total entries : 3"""39 assert (op == expected)40def test_adding_searching_found(no_db):41 exit_status, _ = run_cmd("./​phone_book add john 1234567890")42 assert exit_status == 043 exit_status, _ = run_cmd("./​phone_book add jack 0987654321")44 assert exit_status == 045 exit_status, _ = run_cmd("./​phone_book add james 5432167890")46 assert exit_status == 047 exit_status, op = run_cmd("./​phone_book search john")48 assert exit_status == 049 expected = "1234567890"50 assert (op == expected)51def test_adding_searching_notfound(no_db):52 exit_status, _ = run_cmd("./​phone_book add john 1234567890")53 assert exit_status == 054 exit_status, _ = run_cmd("./​phone_book add jack 0987654321")55 assert exit_status == 056 exit_status, _ = run_cmd("./​phone_book add james 5432167890")57 assert exit_status == 058 exit_status, op = run_cmd("./​phone_book search wick")59 assert exit_status == 160 expected = "no match"61 assert (op == expected)62def test_adding_deleting_nonexistent(no_db):63 exit_status, _ = run_cmd("./​phone_book add john 1234567890")64 assert exit_status == 065 exit_status, _ = run_cmd("./​phone_book add jack 0987654321")66 assert exit_status == 067 exit_status, _ = run_cmd("./​phone_book add james 5432167890")68 assert exit_status == 069 exit_status, op = run_cmd("./​phone_book delete wick")70 assert exit_status == 171 expected = "no match"72 assert (op == expected)73def test_adding_deleting_first_list(no_db):74 exit_status, _ = run_cmd("./​phone_book add john 1234567890")75 assert exit_status == 076 exit_status, _ = run_cmd("./​phone_book add jack 0987654321")77 assert exit_status == 078 exit_status, _ = run_cmd("./​phone_book add james 5432167890")79 assert exit_status == 080 exit_status, op = run_cmd("./​phone_book delete john")81 assert exit_status == 082 exit_status, op = run_cmd("./​phone_book list")83 assert exit_status == 084 expected = """jack : 098765432185james : 543216789086Total entries : 2"""87 assert (op == expected)88 89def test_adding_deleting_middle_list(no_db):90 exit_status, _ = run_cmd("./​phone_book add john 1234567890")91 assert exit_status == 092 exit_status, _ = run_cmd("./​phone_book add jack 0987654321")93 assert exit_status == 094 exit_status, _ = run_cmd("./​phone_book add james 5432167890")95 assert exit_status == 096 exit_status, op = run_cmd("./​phone_book delete jack")97 assert exit_status == 098 exit_status, op = run_cmd("./​phone_book list")99 assert exit_status == 0100 expected = """john : 1234567890101james : 5432167890102Total entries : 2"""103 assert (op == expected)104 105def test_valgrind(no_db):106 run_cmd("./​phone_book add john 1234567890")107 run_cmd("./​phone_book add jack 0987654321")108 run_cmd("./​phone_book add james 5432167890")109 exit_status, op = run_cmd("valgrind ./​phone_book list")110 assert "All heap blocks were freed -- no leaks are possible" in op, "Memory is not being properly freed"111 112 ...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Webinar: Move Forward With An Effective Test Automation Strategy [Voices of Community]

The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.

Dec’22 Updates: The All-New LT Browser 2.0, XCUI App Automation with HyperExecute, And More!

Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.

Developers and Bugs – why are they happening again and again?

Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.

Test Optimization for Continuous Integration

“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

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 yandex-tank 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