Best Python code snippet using tavern
get_proc_mem.py
Source:get_proc_mem.py
...77 test_data = capture_mem(100)78 program_data = server_usage.get_proc_mem([90])79 self.assertEqual(isinstance(program_data, list),80 isinstance(test_data, list))81 def test_pass_dict(self):82 """Function: test_pass_dict83 Description: Test which passes a dictionary for the memory argument.84 Arguments:85 """86 test_data = capture_mem(100)87 program_data = server_usage.get_proc_mem({"key": 90})88 self.assertEqual(isinstance(program_data, list),89 isinstance(test_data, list))90 def test_pass_int(self):91 """Function: test_pass_int92 Description: Test which passes an integer for the memory argument.93 Arguments:94 """95 test_data = capture_mem(90)...
test_link_test.py
Source:test_link_test.py
1import json2import pytest3from lib.link_test import *4def test_valid_protocol():5 assert valid_protocol("github.com") == False6 assert valid_protocol("http:/github.com") == False7 assert valid_protocol("https://github.com") == True8 assert valid_protocol("https:/github.com") == False9def test_link_check():10 assert link_check("https://www.github.com")11def test_linkCheck_fail():12 with pytest.raises(Exception):13 assert link_check("ThisDoesNotExist")14 assert link_check("http://ThisDoesNotExist.com")15 assert link_check("https://ThisDoesNotExist.com")16 assert link_check("http://www.ThisDoesNotExist.com")17 assert link_check("https://www.ThisDoesNotExist.com")18 assert link_check("https:/www.github.com")19def test_validate_json():20 url = "https://github.com"21 test_pass_dict = {22 "url": url23 }24 test_pass_json = json.dumps(test_pass_dict)25 get_url_from_json = validate_json(json.loads(test_pass_json))26 assert get_url_from_json == url27def test_validate_json_fail():28 with pytest.raises(Exception):29 url = "https://github.com"30 test_fail_dict = {31 "urlbad": url32 }33 test_fail_json = json.dumps(test_fail_dict)...
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!!