Best Python code snippet using autotest_python
topic_common_unittest.py
Source:topic_common_unittest.py
...6import unittest, os, sys, urllib27import common8from autotest_lib.cli import cli_mock, topic_common, rpc9class topic_common_misc_tests(unittest.TestCase):10 def test_get_item_key(self):11 get_item_key = topic_common._get_item_key12 self.assertRaises(ValueError, get_item_key, {}, '')13 self.assertRaises(ValueError, get_item_key, {}, '.')14 self.assertRaises(KeyError, get_item_key, {}, 'a')15 self.assertRaises(KeyError, get_item_key, {}, 'a.')16 self.assertRaises(ValueError, get_item_key, {'a': {}}, 'a.')17 self.assertRaises(KeyError, get_item_key, {'a': {}}, 'a.b')18 self.assertEquals(2, get_item_key({'a.b': 2, 'a': {}}, 'a.b'))19 self.assertEquals(9, get_item_key({'a': {'b': 9}}, 'a.b'))20 self.assertEquals(3, get_item_key({'a': {'b': {'c': 3}}}, 'a.b.c'))21 self.assertEquals(5, get_item_key({'a': 5}, 'a'))22 self.assertEquals({'b': 9}, get_item_key({'a': {'b': 9}}, 'a'))23class item_parse_info_unittest(cli_mock.cli_unittest):24 def __test_parsing_flist_bad(self, options):...
cart_calculator_test.py
Source:cart_calculator_test.py
...84 prices = cart_calculator.get_prices()85 assert sorted(prices.keys()) == sorted(dummy_prices.keys())86 for key, value in prices.items():87 assert dummy_prices[key] == value88 def test_get_item_key(self, cart_calculator: CartCalculator):89 cart_calculator.base_prices = dummy_base_prices90 cart_calculator.get_options_order()91 key = cart_calculator.get_item_key(dummy_cart[0])92 assert key == "product_1_red_lg"93 def test_throws(self, cart_calculator: CartCalculator):94 """95 Test various functions throw if they are called too early96 """97 with pytest.raises(Exception):98 cart_calculator.get_item_key(dummy_cart[0])99 with pytest.raises(Exception):...
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!!