예제 #1
0
 def test_should_not_differ_param_order(self):
     files = 'test_files/text.txt'
     param = '-cwl'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\t2\t7\t24 test_files/text.txt\n')
     param = '-wcl'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\t2\t7\t24 test_files/text.txt\n')
     param = '-wlc'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\t2\t7\t24 test_files/text.txt\n')
     param = '-lcw'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\t2\t7\t24 test_files/text.txt\n')
예제 #2
0
 def test_should_count_all_with_multiple_files_given(self):
     file1 = 'test_files/text.txt'
     file2 = 'test_files/text2.txt'
     testargs = ['test_PyWC', file1, file2]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(),
                          '\t2\t7\t24 test_files/text.txt\n'
                          '\t6\t13\t62 test_files/text2.txt\n'
                          '\t8\t20\t86 total')
예제 #3
0
 def test_should_print_file_not_exist(self):
     files = 'non_existing_file_path.txt'
     param = '-lwc'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\tPyWc: ' + files + ' : open: No such file or directory\n')
예제 #4
0
 def test_should_count_all_with_only_file_given(self):
     files = 'test_files/text.txt'
     testargs = ['test_PyWC', files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\t2\t7\t24 test_files/text.txt\n')
예제 #5
0
 def test_should_treat_int_as_string(self):
     files = '1'
     param = '-lwc'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\tPyWc: ' + str(files) + ' : open: No such file or directory\n')
예제 #6
0
 def test_should_count_only_words_and_characters(self):
     files = 'test_files/text.txt'
     param = '-wc'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\t7\t24 test_files/text.txt\n')
예제 #7
0
 def test_should_count_only_lines(self):
     files = 'test_files/text.txt'
     param = '-l'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\t2 test_files/text.txt\n')
예제 #8
0
 def test_should_print_file_is_a_directory(self):
     files = 'test_files'
     param = '-lwc'
     testargs = ['test_PyWC', param, files]
     with patch.object(sys, 'argv', testargs):
         self.assertEqual(PyWc.wc(), '\tPyWc: ' + files + ' : read: Is a directory\n')