Best Python code snippet using autotest_python
test_scanner.py
Source:test_scanner.py
...46 as thorough as possible but are not exhaustive.47 """48 def test_make_scanner_correct(self):49 """50 Description: Ensures that the py_make_scanner() function51 correctly configures the scan_once() function with52 the correct parameters.53 Input: A context containing default values for each54 member.55 Output: An instance of the py_make_scanner:scan_once()56 function.57 Test Case: Corresponds to test case TEST-0087.58 """59 context = ScannerContext()60 scan_once = scanner.py_make_scanner(context)61 # TODO: Perform testing here62 def test_make_scanner_none(self):63 """64 Description: Ensures that the py_make_scanner() function65 errors out when given a None type context parameter.66 Input:67 This test case accepts no input.68 Output:69 (Error)70 Test Case: Corresponds to test case TEST-0088.71 """72 context = None73 self.assertRaises(74 TypeError, # should raise a TypeError75 scanner.py_make_scanner,76 context77 )78 def test_make_scanner_scan_once_correct(self):79 """80 Description: Tests that the py_make_scanner:scan_once()81 function properly scans a JSON token given correct82 parameters.83 Input:84 (str, int): ("["abc", "def", "ghi"]", 0)85 Output:86 (list): ["abc", "def", "ghi"]87 Test Case: Corresponds to test case TEST-0092.88 """89 test_input = "[\"abc\", \"def\", \"ghi\"]"90 test_output = ["abc", "def", "ghi"]91 context = ScannerContext()92 scan_once = scanner.py_make_scanner(context)93 output, _ = scan_once(test_input, 0)94 self.assertEqual(output, test_output)95 def test_make_scanner_scan_once_none(self):96 """97 Description: Tests that the py_make_scanner:scan_once()98 function errors out when given a None type as the input99 string.100 Input:101 (None, int): (None, 0)102 Output:103 (JSONDecodeError)104 Test Case: Corresponds to test case TEST-0093.105 """106 test_input = (None, 0)107 context = ScannerContext()108 scan_once = scanner.py_make_scanner(context)109 self.assertRaises(110 errors.JSONDecodeError,111 scan_once,112 test_input[0],113 test_input[1]114 )115 def test_make_scanner_scan_once_iindex(self):116 """117 Description: Tests that the py_make_scanner:scan_once()118 function errors out when given a valid JSON string as the119 input string and an invalid index.120 Input:121 (str, int): ("["abc", "def", "ghi"]", -1)122 Output:123 (JSONDecodeError)124 Test Case: Corresponds to test case TEST-0094.125 """126 test_input = ("[\"abc\", \"def\", \"ghi\"]", -1)127 context = ScannerContext()128 scan_once = scanner.py_make_scanner(context)129 self.assertRaises(130 errors.JSONDecodeError,131 scan_once,132 test_input[0],133 test_input[1]...
scanner.py
Source:scanner.py
...8__all__ = ['make_scanner']9NUMBER_RE = re.compile(10 r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?',11 (re.VERBOSE | re.MULTILINE | re.DOTALL))12def py_make_scanner(context):13 parse_object = context.parse_object14 parse_array = context.parse_array15 parse_string = context.parse_string16 match_number = NUMBER_RE.match17 strict = context.strict18 parse_float = context.parse_float19 parse_int = context.parse_int20 parse_constant = context.parse_constant21 object_hook = context.object_hook22 object_pairs_hook = context.object_pairs_hook23 memo = context.memo24 def _scan_once(string, idx):25 try:26 nextchar = string[idx]...
lzma_libt0.5_pp2.0_fp1.0_5.py
Source:lzma_libt0.5_pp2.0_fp1.0_5.py
...12json.decoder.JSONDecoder()13import json.encoder14json.encoder.JSONEncoder()15import json.scanner16json.scanner.py_make_scanner()17import json.tool18json.tool.main()19import json.decoder20json.decoder.JSONDecoder()21import json.encoder22json.encoder.JSONEncoder()23import json.scanner24json.scanner.py_make_scanner()25import json.tool26json.tool.main()27import json.decoder28json.decoder.JSONDecoder()29import json.encoder30json.encoder.JSONEncoder()31import json.scanner32json.scanner.py_make_scanner()33import json.tool...
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!!