From 9d62d3217bd8cad260accf87adf9e643fe9e9e8c Mon Sep 17 00:00:00 2001 From: "Mr. Python" <2789762371@qq.com> Date: Sun, 15 Dec 2024 20:17:32 +0800 Subject: [PATCH] replace "python" with "sys.executable" (#157) --- .pylintrc | 2 +- cyaron/tests/compare_test.py | 10 +++++----- cyaron/tests/io_test.py | 11 +++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.pylintrc b/.pylintrc index de2c0b1..61e0596 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,3 +1,3 @@ [MASTER] -py-version=3.5 +py-version=3.6 disable=R0902,R0903,R0913,R0917,R0912 \ No newline at end of file diff --git a/cyaron/tests/compare_test.py b/cyaron/tests/compare_test.py index c52a6a7..fe584b7 100644 --- a/cyaron/tests/compare_test.py +++ b/cyaron/tests/compare_test.py @@ -81,13 +81,13 @@ def test_fulltext_program(self): try: with captured_output() as (out, err): - Compare.program("python correct.py", - "python incorrect.py", + Compare.program(f"{sys.executable} correct.py", + f"{sys.executable} incorrect.py", std=io, input=io, grader="FullText") except CompareMismatch as e: - self.assertEqual(e.name, 'python incorrect.py') + self.assertEqual(e.name, f"{sys.executable} incorrect.py") e = e.mismatch self.assertEqual(e.content, '2\n') self.assertEqual(e.std, '1\n') @@ -120,8 +120,8 @@ def test_file_input(self): io.input_writeln("233") with captured_output() as (out, err): - Compare.program("python correct.py", - std_program="python std.py", + Compare.program(f"{sys.executable} correct.py", + std_program=f"{sys.executable} std.py", input=io, grader="NOIPStyle") diff --git a/cyaron/tests/io_test.py b/cyaron/tests/io_test.py index 42cb996..c60786c 100644 --- a/cyaron/tests/io_test.py +++ b/cyaron/tests/io_test.py @@ -1,8 +1,9 @@ -import unittest import os import shutil -import tempfile import subprocess +import sys +import tempfile +import unittest from cyaron import IO from cyaron.output_capture import captured_output @@ -80,7 +81,8 @@ def test_output_gen_time_limit_exceeded(self): try: with IO("test_gen.in", "test_gen.out") as test: - test.output_gen("python long_time.py", time_limit=1) + test.output_gen(f"{sys.executable} long_time.py", + time_limit=1) except subprocess.TimeoutExpired: time_limit_exceeded = True self.assertEqual(time_limit_exceeded, True) @@ -93,7 +95,8 @@ def test_output_gen_time_limit_not_exceeded(self): try: with IO("test_gen.in", "test_gen.out") as test: - test.output_gen("python short_time.py", time_limit=1) + test.output_gen(f"{sys.executable} short_time.py", + time_limit=1) except subprocess.TimeoutExpired: time_limit_exceeded = True with open("test_gen.out") as f: