How to use get_target_files method in avocado

Best Python code snippet using avocado_python

test_utils_diff_validator.py

Source:test_utils_diff_validator.py Github

copy

Full Screen

...15 f.write("")16 with open(self.files[1], "w") as f:17 f.write("")18 def tearDown(self):19 diff_validator.del_temp_file_copies(self.change.get_target_files())20 self.tmpdir.cleanup()21 def test_change_success(self):22 files = self.files23 with open(files[0], "w") as f:24 f.write("this line is removed\n")25 with open(files[1], "w") as f:26 f.write("this line is not removed\n")27 change = self.change28 change.add_validated_files(files)29 change.append_expected_add(files[0], "this is a new line")30 change.append_expected_remove(files[0], "this line is removed")31 change.append_expected_add(files[1], "this is a new line again")32 diff_validator.make_temp_file_copies(change.get_target_files())33 with open(files[0], "w") as f:34 f.write("this is a new line")35 with open(files[1], "w") as f:36 f.write("this line is not removed\nthis is a new line again\n")37 changes = diff_validator.extract_changes(change.get_target_files())38 change_success = diff_validator.assert_change(changes, change.files_dict)39 change_dict = diff_validator.assert_change_dict(changes, change.files_dict)40 self.assertTrue(change_success, "The change must be valid:\n%s" % diff_validator.create_diff_report(change_dict))41 def test_change_wrong_no_change(self):42 files = self.files43 with open(files[0], "w") as f:44 f.write("this line is removed\n")45 change = self.change46 change.add_validated_files(files)47 change.append_expected_add(files[0], "this is a new line")48 change.append_expected_remove(files[0], "this line is removed")49 diff_validator.make_temp_file_copies(change.get_target_files())50 changes = diff_validator.extract_changes(change.get_target_files())51 change_success = diff_validator.assert_change(changes, change.files_dict)52 change_dict = diff_validator.assert_change_dict(changes, change.files_dict)53 self.assertFalse(change_success, "The change must not be valid:\n%s" % diff_validator.create_diff_report(change_dict))54 def test_change_wrong_add(self):55 files = self.files56 with open(files[0], "w") as f:57 f.write("this line is removed\n")58 change = self.change59 change.add_validated_files(files)60 change.append_expected_add(files[0], "this is a new line")61 change.append_expected_remove(files[0], "this line is removed")62 diff_validator.make_temp_file_copies(change.get_target_files())63 with open(files[0], "w") as f:64 f.write("this is a wrong new line\n")65 changes = diff_validator.extract_changes(change.get_target_files())66 change_success = diff_validator.assert_change(changes, change.files_dict)67 change_dict = diff_validator.assert_change_dict(changes, change.files_dict)68 self.assertFalse(change_success, "The change must not be valid:\n%s" % diff_validator.create_diff_report(change_dict))69 def test_change_unexpected_remove(self):70 files = self.files71 with open(files[0], "w") as f:72 f.write("this line is removed\n")73 change = self.change74 change.add_validated_files(files)75 change.append_expected_add(files[0], "this is a new line")76 diff_validator.make_temp_file_copies(change.get_target_files())77 with open(files[0], "w") as f:78 f.write("this is a new line\n")79 changes = diff_validator.extract_changes(change.get_target_files())80 change_success = diff_validator.assert_change(changes, change.files_dict)81 change_dict = diff_validator.assert_change_dict(changes, change.files_dict)82 self.assertFalse(change_success, "The change must not be valid:\n%s" % diff_validator.create_diff_report(change_dict))83 def test_change_unexpected_add(self):84 files = self.files85 with open(files[0], "w") as f:86 f.write("this line is removed\n")87 change = self.change88 change.add_validated_files(files)89 change.append_expected_remove(files[0], "this line is removed")90 diff_validator.make_temp_file_copies(change.get_target_files())91 with open(files[0], "w") as f:92 f.write("this is an unexpected new line\n")93 changes = diff_validator.extract_changes(change.get_target_files())94 change_success = diff_validator.assert_change(changes, change.files_dict)95 change_dict = diff_validator.assert_change_dict(changes, change.files_dict)96 self.assertFalse(change_success, "The change must not be valid:\n%s" % diff_validator.create_diff_report(change_dict))97if __name__ == '__main__':...

Full Screen

Full Screen

python.py

Source:python.py Github

copy

Full Screen

1import os2import re3import pandas as pd4resource_dir = ".resoutces/sources/"5def get_target_files(prefix):6 """Get the target files."""7 target_files = [file for file in os.listdir(resource_dir) if file.startswith(prefix)]8 return target_files9def concat_df(file_names):10 """Read in each csv file and concatenate into one dataframe."""11 all_dfs = [pd.read_csv(resource_dir + f) for f in file_names]12 return pd.concat(all_dfs)13def extract_payment(string):14 payment_reg = r"monthly payment:\s*\${0,1}(\d*)"15 match = re.search(payment_reg, string, re.I)16 try:17 payment = match.group(1)18 return payment19 except AttributeError:20 print(f"Failed to edtract payment. No match for string: {string}")21 return None22def main():23 # get all target file names24 file_names = get_target_files(prefix="20")25# file_names = get_target_files('2018')26 27 # combine all files into one df28 combined_df=concat_df(file_names)29 # assign new column using regex for extraction30 combined_df['payment'] = combined_df['comments'].apply(extract_payment)31 32 # save to csv33 combined_df.to_csv("result.csv", index=False)...

Full Screen

Full Screen

findEvent.py

Source:findEvent.py Github

copy

Full Screen

...13 value = (value ^ np.uint32(ord(c))) * prime_32_const14 if toUint16:15 value = np.uint16(value)16 return value17def get_target_files():18 x = glob.glob('**/*.[ch]??', recursive=True)19 x = filter(lambda y: "CMake" not in y, x)20 x = filter(lambda y: "TESTS" not in y, x)21 x = filter(lambda y: "extern" not in y, x)22 return x23def get_event_map():24 tgts = get_target_files()25 event_names = []26 event_map = defaultdict(list)27 for f in tgts:28 with open(f) as fp:29 for line in fp:30 m = re.match("\s*DECLARE_\w+\((\w+)\)", line)31 if m:32 #print(m)33 event_names.append(m.group(1))34 for evt in event_names:35 x = mHash_fnv1a(evt)36 event_map[x].append(evt)37 pprint(event_map)38 return event_map...

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 avocado 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