codestyle

This commit is contained in:
Egor Matveev
2021-12-02 18:24:51 +03:00
parent 255a364c34
commit d2d427fd6e
25 changed files with 168 additions and 378 deletions

View File

@@ -63,12 +63,16 @@ class BaseTester:
mkdir("solutions")
mkdir("solutions/" + str(self.solution.id))
for file in SolutionFile.objects.filter(solution=self.solution):
dirs = file.path.split('/')
dirs = file.path.split("/")
for i in range(len(dirs) - 1):
name = join(str("solutions/" + self.solution.id), '/'.join(dirs[:i + 1]))
name = join(
str("solutions/" + self.solution.id), "/".join(dirs[: i + 1])
)
if not exists(name):
mkdir(name)
with open(join("solutions/" + str(self.solution.id), file.path), 'wb') as fs:
with open(
join("solutions/" + str(self.solution.id), file.path), "wb"
) as fs:
fs.write(get_bytes(file.fs_id))
self.solution.result = CONSTS["testing_status"]
self.solution.save()
@@ -77,7 +81,9 @@ class BaseTester:
call(docker_command, shell=True)
print("Container created")
for file in ExtraFile.objects.filter(task=self.solution.task):
with open(join("solutions/" + str(self.solution.id), file.filename), 'wb') as fs:
with open(
join("solutions/" + str(self.solution.id), file.filename), "wb"
) as fs:
fs.write(get_bytes(file.fs_id))
print("Files copied")
try:

View File

@@ -7,13 +7,17 @@ class JavaTester(BaseTester):
_executable = None
def before_test(self):
files = [file for file in listdir(self.solution.testing_directory) if file.endswith('.java')]
files = [
file
for file in listdir(self.solution.testing_directory)
if file.endswith(".java")
]
code = self.solution.exec_command(f"javac {' '.join(files)}")
if code != 0:
raise TestException('CE')
raise TestException("CE")
for file in listdir(self.solution.testing_directory):
if file.endswith('.class'):
self._executable = file.rstrip('.class')
if file.endswith(".class"):
self._executable = file.rstrip(".class")
break
if self._executable is None:
raise TestException("TE")

View File

@@ -5,10 +5,16 @@ from SprintLib.testers.BaseTester import BaseTester, TestException
class KotlinTester(BaseTester):
def before_test(self):
files = [file for file in listdir(self.solution.testing_directory) if file.endswith('.kt')]
code = self.solution.exec_command(f'kotlinc {" ".join(files)} -include-runtime -d solution.jar')
files = [
file
for file in listdir(self.solution.testing_directory)
if file.endswith(".kt")
]
code = self.solution.exec_command(
f'kotlinc {" ".join(files)} -include-runtime -d solution.jar'
)
if code != 0:
raise TestException('CE')
raise TestException("CE")
@property
def command(self):