Skip to content

Commit fbfb37a

Browse files
committed
check if files exist before doing stuff with them
1 parent 66a8eab commit fbfb37a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/tests/test_modules.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
import os
23
import subprocess
34

45
from gradescope_utils.autograder_utils.decorators import weight, number
@@ -35,10 +36,16 @@ def runCPUEmulator(self, dirname, name):
3536
except subprocess.TimeoutExpired as err:
3637
raise TimeoutError(f'Emulator timed out out after {err.timeout} seconds:\n{str(err.stdout).strip()}')
3738

39+
def assertFileExists(self, path):
40+
if not os.path.isfile(path):
41+
raise AssertionError(f'File "{path}" does not exist!')
42+
3843
def assertCorrectTranslator(self, dirname):
3944
_, name = dirname.split('/')
4045
self.runStudentCode(dirname, name)
46+
self.assertFileExists(f'/autograder/source/{dirname}/{name}.asm')
4147
self.assertValidAssembly(dirname, name)
48+
self.assertFileExists(f'/autograder/source/{dirname}/{name}.out')
4249
self.runCPUEmulator(dirname, name)
4350

4451
class TestModules(TestBase):

0 commit comments

Comments
 (0)