Beispiel #1
0
 def test_init_special_chars(self):
     sys.argv = [
         'transpose.py', f'{pytest.TEST_DATA_FOLDER}/special_chars.txt'
     ]
     expected = '@#$^&\n&^$#@'
     with patch('sys.stdout', new=StringIO()) as output:
         init()
     self.assertEqual(output.getvalue().strip(), expected)
Beispiel #2
0
 def test_init_spaced_words(self):
     sys.argv = [
         'transpose.py', f'{pytest.TEST_DATA_FOLDER}/spaced_words.txt'
     ]
     expected = 'jumps over the\neht revo spmuj'
     with patch('sys.stdout', new=StringIO()) as output:
         init()
     self.assertEqual(output.getvalue().strip(), expected)
Beispiel #3
0
 def test_init_numbers(self):
     sys.argv = [
         'transpose.py', f'{pytest.TEST_DATA_FOLDER}/numbers_file.txt'
     ]
     expected = '12345\n54321'
     with patch('sys.stdout', new=StringIO()) as output:
         init()
     self.assertEqual(output.getvalue().strip(), expected)
Beispiel #4
0
 def test_init(self):
     sys.argv = [
         'transpose.py', f'{pytest.TEST_DATA_FOLDER}/example_file.txt'
     ]
     expected = 'abcde\nedcba'
     with patch('sys.stdout', new=StringIO()) as output:
         init()
     self.assertEqual(output.getvalue().strip(), expected)
Beispiel #5
0
 def test_init_invalid_args(self):
     sys.argv = ['transpose.py']
     with self.assertRaises(IndexError):
         init()
Beispiel #6
0
 def test_init_file_not_found(self):
     sys.argv = ['transpose.py', f'{pytest.TEST_DATA_FOLDER}/test_data.txt']
     with self.assertRaises(FileNotFoundError):
         init()