sprint/SprintLib/testers/JavaTester.py
2022-05-03 08:42:21 +03:00

28 lines
757 B
Python

from os import listdir
from SprintLib.testers.BaseTester import BaseTester, TestException
class JavaTester(BaseTester):
_executable = None
def before_test(self):
files = [
file
for file in listdir(self.path)
if file.endswith(".java")
]
code = self.solution.exec_command(f"javac {' '.join(files)}")
if code != 0:
raise TestException("CE")
for file in listdir(self.path):
if file.endswith(".class"):
self._executable = file.rstrip(".class")
break
if self._executable is None:
raise TestException("TE")
@property
def command(self):
return f"java -classpath . {self._executable}"