How to use test_empty_file method in avocado

Best Python code snippet using avocado_python

test_project.py

Source:test_project.py Github

copy

Full Screen

...7 file.write(8 """5\nA\tB\nB\tA\nA\tA\nA\tC\nC\tB"""9 )10class Test_read_interaction_file_dict:11 def test_empty_file(self):12 with open("/tmp/testFile", 'w'): pass13 assert project.read_interaction_file_dict("/tmp/testFile") == dict()14 os.remove("/tmp/testFile")15 def test_usual_file(self):16 write_example("/tmp/testFile")17 assert len(project.read_interaction_file_dict("/tmp/testFile")) == 318 assert project.read_interaction_file_dict("/tmp/testFile") == {"A":{"A","B","C"},19 "B":{"A","C"},20 "C":{"A","B"}}21 os.remove("/tmp/testFile")22class Test_read_interaction_file_list:23 def test_empty_file(self):24 with open("/tmp/testFile", 'w'): pass25 assert project.read_interaction_file_list("/tmp/testFile") == list()26 os.remove("/tmp/testFile")27 def test_usual_file(self):28 write_example("/tmp/testFile")29 assert len(project.read_interaction_file_list("/tmp/testFile")) == 530 assert project.read_interaction_file_list("/tmp/testFile") == [("A","B"),("B","A"),("A","A"),("A","C"),("C","B")]31 os.remove("/tmp/testFile")32class Test_read_interaction_file_mat:33 def test_empty_file(self):34 with open("/tmp/testFile", 'w'): pass35 assert np.size(project.read_interaction_file_mat("/tmp/testFile")[0]) == 036 assert project.read_interaction_file_mat("/tmp/testFile")[1] == []37 os.remove("/tmp/testFile")38 def test_usual_file_matrix_size(self):39 write_example("/tmp/testFile")40 assert np.size(project.read_interaction_file_mat("/tmp/testFile")[0]) == 941 os.remove("/tmp/testFile")42 def test_usual_file_matrix_parallel(self):43 write_example("/tmp/testFile")44 matrix = project.read_interaction_file_mat("/tmp/testFile")[0]45 for i in range(3):46 for j in range(3):47 assert matrix[i, j] == matrix[j, i]48 os.remove("/tmp/testFile")49 def test_usual_file_list_content(self):50 write_example("/tmp/testFile")51 vertices_list = project.read_interaction_file_mat("/tmp/testFile")[1]52 assert set(vertices_list) == {"A", "B", "C"}53 os.remove("/tmp/testFile")54class Test_count_vertices:55 def test_empty_file(self):56 with open("/tmp/testFile", 'w'): pass57 assert project.count_vertices("/tmp/testFile") == 058 os.remove("/tmp/testFile")59 def test_usual_file(self):60 write_example("/tmp/testFile")61 assert project.count_vertices("/tmp/testFile") == 362 os.remove("/tmp/testFile")63class Test_count_edges:64 def test_empty_file(self):65 with open("/tmp/testFile", 'w'): pass66 assert project.count_edges("/tmp/testFile") == 067 os.remove("/tmp/testFile")68 def test_usual_file(self):69 write_example("/tmp/testFile")70 assert project.count_edges("/tmp/testFile") == 571 os.remove("/tmp/testFile")72class Test_clean_interactome:73 def test_usual_file(self):74 write_example("/tmp/testFile")75 project.clean_interactome("/tmp/testFile", "/tmp/testFileOut")76 with open("/tmp/testFileOut", "r") as content:77 for line in content:78 assert line.rstrip() in ("3", "A\tB", "A\tC", "C\tB") ...

Full Screen

Full Screen

test_speed_reader.py

Source:test_speed_reader.py Github

copy

Full Screen

1from speed_reader import Speed_reader2import unittest3class TestSpeedReader(unittest.TestCase):4 def test_list_init(self):5 pass6 def test_initialize_word_list(self):7 8 test_empty_file_read = Speed_reader("Test_files/empty_msg.txt")9 empty_file_contents = test_empty_file_read.initialize_word_list(test_empty_file_read.file_name)10 self.assertEqual(empty_file_contents, [])11 test_file_read = Speed_reader("Test_files/short_msg.txt")12 short_msg_contents = test_file_read.initialize_word_list(test_file_read.file_name)13 self.assertEqual(short_msg_contents, [['This', 'is', 'a', 'short', 'message', '.'], 14 ['The', 'program', 'should', 'be', 'able', 'to', 'split', 'this', 'up', '.'],15 ['Let', "'s", 'see', 'if', 'it', 'can', 'do', 'it', '.']])16 17 def test_get_output(self):18 test_empty_file = Speed_reader("Test_files/empty_msg.txt")19 self.assertEqual(test_empty_file.get_output(0,0, 3), ('', 0, 1, 1))20 test_small_file = Speed_reader("Test_files/short_msg.txt")21 self.assertEqual(test_small_file.get_output(0,0, 3), ('This is a', 3, 0, 0))22 self.assertEqual(test_small_file.get_output(0,3, 5), ('short message .', 0, 1, 1))23 self.assertEqual(test_small_file.get_output(2,0, 4), ('Let \'s see if', 4, 0, 2))24 self.assertEqual(test_small_file.get_output(2, 4, 1), ('it', 5, 0, 2))25 self.assertEqual(test_small_file.get_output(2, 5, 3), ('can do it', 8, 0, 2))26 self.assertEqual(test_small_file.get_output(2, 8, 1), ('.', 0, 1, 3))27 28 def test_button_inner_functionality(self):29 test_empty_file = Speed_reader("Test_files/empty_msg.txt", 600)30 31 # changeRefreshRate()32 self.assertEqual(test_empty_file.changeRefreshRate(600, -25), 575)33 self.assertEqual(test_empty_file.changeRefreshRate(600, 100), 700)34 self.assertEqual(test_empty_file.changeRefreshRate(50, -150), 50)35 # flipPauseFlag()36 self.assertEqual(test_empty_file.flipPauseFlag(100), 0)37 self.assertEqual(test_empty_file.flipPauseFlag(0), 1)38 self.assertEqual(test_empty_file.flipPauseFlag(-10), 0)39 # displaceSentenceIndex()40 self.assertEqual(test_empty_file.displaceSentenceIndex(100), 90)41 self.assertEqual(test_empty_file.displaceSentenceIndex(100, 10), 110)42 self.assertEqual(test_empty_file.displaceSentenceIndex(10, -20), 0)43 self.assertEqual(test_empty_file.displaceSentenceIndex(-20, -10), 0)44 # changeNumWordsOutput()45 self.assertEqual(test_empty_file.changeNumWordsOutput(2, 1), 3)46 self.assertEqual(test_empty_file.changeNumWordsOutput(3, -1), 2)47 self.assertEqual(test_empty_file.changeNumWordsOutput(1, -1), 1)48 self.assertEqual(test_empty_file.changeNumWordsOutput(10, -11), 10)49 # changeNumSentencesPerPlacement()50 self.assertEqual(test_empty_file.changeNumSentencesPerPlacement(1, -1), 1)51 self.assertEqual(test_empty_file.changeNumSentencesPerPlacement(5, -4), 1)52 self.assertEqual(test_empty_file.changeNumSentencesPerPlacement(1, 1), 2)53 self.assertEqual(test_empty_file.changeNumSentencesPerPlacement(5, 4), 9)54 def test_tkinter(self):55 pass56 57if __name__ == '__main__':58 Speed_reader("Test_files/test_data.txt")...

Full Screen

Full Screen

test_app.py

Source:test_app.py Github

copy

Full Screen

...16'''17Test empty file:18 This file is empty. Test that it in fact adds no words.19'''20def test_empty_file():21 put_url = f"{base_url}/put-file/"22 data_url = \23 "https://raw.githubusercontent.com/usmansohail/SidenCodeTask/main/tests/example_files/empty_file.txt"24 response = requests.put(put_url, data={"url":data_url})25 assert response.status_code == 20026 assert_correct_counts(0)27'''28Ten unique words:29 This test case adds a file with ten unique words, but 23 total lines. This30 test will ensure that words are successfully inserted and also duplicates31 are handled correctly.32'''33def test_ten_unique_words():34 put_url = f"{base_url}/put-file/"35 data_url = \36 "https://raw.githubusercontent.com/usmansohail/SidenCodeTask/main/tests/example_files/ten_unique_words.txt"37 response = requests.put(put_url, data={"url":data_url})38 assert response.status_code == 20039 assert_correct_counts(10)40 # cleanup by putting the empty file again41 test_empty_file()42'''43Special characters:44 This test case adds a file with ten unique special characters, but 23 total45 lines. This test will ensure that words are successfully inserted even46 though they are all special characters.47'''48def test_special_characters():49 put_url = f"{base_url}/put-file/"50 data_url = \51 "https://raw.githubusercontent.com/usmansohail/SidenCodeTask/main/tests/example_files/special_chars.txt"52 response = requests.put(put_url, data={"url":data_url})53 assert response.status_code == 20054 assert_correct_counts(10)55 # cleanup by putting the empty file again56 test_empty_file()57def test_put_provided_file():58 put_url = f"{base_url}/put-file/"59 data_url = \60 "https://raw.githubusercontent.com/usmansohail/SidenCodeTask/main/tests/example_files/siden_coding_test_file_sample.txt"61 response = requests.put(put_url, data={"url":data_url})62 assert response.status_code == 20063 assert_correct_counts(3023)64 # cleanup by putting the empty file again...

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