コード例 #1
0
 def test_numArgs_too_many(self):
     from unittest.mock import patch
     with patch(target='sys.argv',
                new=['numArgs_too_many.py', self.asm_filename, 'bad.asm']):
         with self.assertRaises(SystemExit):
             (file_asm, file_list, file_mem, file_sym,
              file_mif) = as240.parse_command_line()
コード例 #2
0
 def test_bad_asmfilename(self):
     from unittest.mock import patch
     with patch(target='sys.argv',
                new=['bad_asm_filename.py', 'asmfilename.asm']):
         with self.assertRaises(SystemExit):
             (file_asm, file_list, file_mem, file_sym,
              file_mif) = as240.parse_command_line()
コード例 #3
0
 def test_specify_stdout_listonly(self):
     from unittest.mock import patch
     command_line = ['stdout_listonly.py', self.asm_filename, '-o']
     with patch(target='sys.argv', new=command_line):
         (file_asm, file_list, file_mem, file_sym,
          file_mif) = as240.parse_command_line()
         self.assertEqual(file_asm.name, self.asm_filename)
         self.assertEqual(file_list.name, '<stdout>')
         self.assertEqual(file_mem.name, '/dev/null')
         self.assertEqual(file_sym.name, '/dev/null')
         self.assertEqual(file_mif.name, '/dev/null')
     file_asm.close()
     file_list.close()
     file_mem.close()
     file_sym.close()
     file_mif.close()
コード例 #4
0
 def test_good_asmfile(self):
     from unittest.mock import patch
     with patch(target='sys.argv',
                new=['good_asmfile.py', self.asm_filename]):
         (file_asm, file_list, file_mem, file_sym,
          file_mif) = as240.parse_command_line()
         self.assertEqual(file_asm.name, self.asm_filename)
         self.assertEqual(file_list.name, self.asm_file_basename + '.list')
         self.assertEqual(file_mem.name, 'memory.hex')
         self.assertEqual(file_sym.name, '/dev/null')
         self.assertEqual(file_mif.name, 'memory.mif')
         file_asm.close()
         file_list.close()
         file_mem.close()
         file_sym.close()
         file_mif.close()
コード例 #5
0
 def test_specify_miffile(self):
     rand_string = str(random.randrange(0, 100000))
     rand_name = f'tmp_{rand_string}'
     from unittest.mock import patch
     command_line = [
         'specify_miffile.py', self.asm_filename, '--miffilename', rand_name
     ]
     with patch(target='sys.argv', new=command_line):
         (file_asm, file_list, file_mem, file_sym,
          file_mif) = as240.parse_command_line()
         self.assertEqual(file_asm.name, self.asm_filename)
         self.assertEqual(file_list.name, self.asm_file_basename + '.list')
         self.assertEqual(file_mem.name, 'memory.hex')
         self.assertEqual(file_sym.name, '/dev/null')
         self.assertEqual(file_mif.name, rand_name)
         file_asm.close()
         file_list.close()
         file_mem.close()
         file_sym.close()
         file_mif.close()
コード例 #6
0
 def test_specify_stdout_plusall(self):
     rand_string = str(random.randrange(0, 100000))
     rand_name = f'tmp_{rand_string}'
     from unittest.mock import patch
     command_line = [
         'specify_stdout_plusall.py', self.asm_filename, '-o', '-m',
         rand_name + '.mem', '-s', rand_name + '.sym', '--miffilename',
         rand_name + '.mif'
     ]
     with patch(target='sys.argv', new=command_line):
         (file_asm, file_list, file_mem, file_sym,
          file_mif) = as240.parse_command_line()
         self.assertEqual(file_asm.name, self.asm_filename)
         self.assertEqual(file_list.name, '<stdout>')
         self.assertEqual(file_mem.name, rand_name + '.mem')
         self.assertEqual(file_sym.name, rand_name + '.sym')
         self.assertEqual(file_mif.name, rand_name + '.mif')
         file_asm.close()
         file_list.close()
         file_mem.close()
         file_sym.close()
         file_mif.close()