Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否应该将 test 中的 python 替换为 sys.executable #157

Open
weilycoder opened this issue Dec 9, 2024 · 8 comments
Open

是否应该将 test 中的 python 替换为 sys.executable #157

weilycoder opened this issue Dec 9, 2024 · 8 comments

Comments

@weilycoder
Copy link
Contributor

替换的理由如下:

2024-12-09_23-01

@Mr-Python-in-China
Copy link
Collaborator

9d62d32

@weilycoder
Copy link
Contributor Author

坏了,这是为啥?

@Mr-Python-in-China
Copy link
Collaborator

坏了,这是为啥?

原先test写死了

有空我再改改

@weilycoder
Copy link
Contributor Author

weilycoder commented Dec 15, 2024

还真是,不过你没修改完:

correct_out = 'python correct.py: Correct \npython incorrect.py: !!!INCORRECT!!! Hash mismatch: read 53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3, expected 4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865'

至少把包括这一行的 python 都替换掉在本地是能过的。

@Mr-Python-in-China
Copy link
Collaborator

我看报错好像很麻烦

好像不止这一处

@Mr-Python-in-China
Copy link
Collaborator

你试试用python3之类的文件名跑test?

@weilycoder
Copy link
Contributor Author

weilycoder commented Dec 15, 2024

没看懂你的表达,但我用一个新程序把 python 覆盖了,你看看输出:

Details

PS *****\cyaron> C:\Python312\python.exe unit_test.py
test_concurrent (cyaron.tests.compare_test.TestCompare.test_concurrent) ... ('C:\\Python312\\python.exe', 'test2.py'): Correct
('C:\\Python312\\python.exe', 'test1.py'): Correct
('C:\\Python312\\python.exe', 'test6.py'): Correct
('C:\\Python312\\python.exe', 'test4.py'): Correct
('C:\\Python312\\python.exe', 'test5.py'): Correct
('C:\\Python312\\python.exe', 'test9.py'): Correct
('C:\\Python312\\python.exe', 'test7.py'): Correct
('C:\\Python312\\python.exe', 'test0.py'): Correct
('C:\\Python312\\python.exe', 'test8.py'): Correct
('C:\\Python312\\python.exe', 'test10.py'): Correct
('C:\\Python312\\python.exe', 'test3.py'): Correct
('C:\\Python312\\python.exe', 'test11.py'): Correct
('C:\\Python312\\python.exe', 'test13.py'): Correct
('C:\\Python312\\python.exe', 'test12.py'): Correct
('C:\\Python312\\python.exe', 'test15.py'): Correct
('C:\\Python312\\python.exe', 'test14.py'): Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
None: Correct
ok
test_file_input (cyaron.tests.compare_test.TestCompare.test_file_input) ... python
std.py
ERROR
test_fulltext_program (cyaron.tests.compare_test.TestCompare.test_fulltext_program) ... python
correct.py
ERROR
test_noipstyle_correct (cyaron.tests.compare_test.TestCompare.test_noipstyle_correct) ... ok
test_noipstyle_incorrect (cyaron.tests.compare_test.TestCompare.test_noipstyle_incorrect) ... ok
test_timeout (cyaron.tests.compare_test.TestCompare.test_timeout) ... ok
test_DAG (cyaron.tests.graph_test.TestGraph.test_DAG) ... ok
test_DAG_boundary (cyaron.tests.graph_test.TestGraph.test_DAG_boundary) ... ok
test_DAG_without_loop (cyaron.tests.graph_test.TestGraph.test_DAG_without_loop) ... ok
test_GraphMatrix (cyaron.tests.graph_test.TestGraph.test_GraphMatrix) ... ok
test_forest (cyaron.tests.graph_test.TestGraph.test_forest) ... ok
test_repeated_edges (cyaron.tests.graph_test.TestGraph.test_repeated_edges) ... ok
test_self_loop (cyaron.tests.graph_test.TestGraph.test_self_loop) ... ok
test_tree_connected (cyaron.tests.graph_test.TestGraph.test_tree_connected) ... ok
test_undirected_graph (cyaron.tests.graph_test.TestGraph.test_undirected_graph) ... ok
test_create_files_prefix_id (cyaron.tests.io_test.TestIO.test_create_files_prefix_id) ... ok
test_create_files_simple (cyaron.tests.io_test.TestIO.test_create_files_simple) ... ok
test_create_files_without_prefix_id (cyaron.tests.io_test.TestIO.test_create_files_without_prefix_id) ... ok
test_init_overload (cyaron.tests.io_test.TestIO.test_init_overload) ... ok
test_make_dirs (cyaron.tests.io_test.TestIO.test_make_dirs) ... ok
test_output_clear_content (cyaron.tests.io_test.TestIO.test_output_clear_content) ... ok
test_output_clear_content_with_position (cyaron.tests.io_test.TestIO.test_output_clear_content_with_position) ... ok
test_output_gen (cyaron.tests.io_test.TestIO.test_output_gen) ... ok
test_output_gen_time_limit_exceeded (cyaron.tests.io_test.TestIO.test_output_gen_time_limit_exceeded) ... python
long_time.py
ERROR
test_output_gen_time_limit_not_exceeded (cyaron.tests.io_test.TestIO.test_output_gen_time_limit_not_exceeded) ... python
short_time.py
ERROR
test_write_stuff (cyaron.tests.io_test.TestIO.test_write_stuff) ... ok
test_convex_hull (cyaron.tests.polygon_test.TestPolygon.test_convex_hull) ... ok
test_perimeter_area (cyaron.tests.polygon_test.TestPolygon.test_perimeter_area) ... ok
test_simple_polygon (cyaron.tests.polygon_test.TestPolygon.test_simple_polygon) ... ok
test_func_get_many (cyaron.tests.sequence_test.TestSequence.test_func_get_many) ... ok
test_func_get_one (cyaron.tests.sequence_test.TestSequence.test_func_get_one) ... ok
test_simple_get_many (cyaron.tests.sequence_test.TestSequence.test_simple_get_many) ... ok
test_simple_get_one (cyaron.tests.sequence_test.TestSequence.test_simple_get_one) ... ok
test_random_paragraph (cyaron.tests.str_test.TestString.test_random_paragraph) ... ok
test_random_regular (cyaron.tests.str_test.TestString.test_random_regular) ... ok
test_random_sentence (cyaron.tests.str_test.TestString.test_random_sentence) ... ok
test_random_word (cyaron.tests.str_test.TestString.test_random_word) ... ok
test_random_word_from_dict (cyaron.tests.str_test.TestString.test_random_word_from_dict) ... ok
test_float_vector (cyaron.tests.vector_test.TestVector.test_float_vector) ... ok
test_repeatable_vector (cyaron.tests.vector_test.TestVector.test_repeatable_vector) ... ok
test_unique_vector (cyaron.tests.vector_test.TestVector.test_unique_vector) ... ok

======================================================================
ERROR: test_file_input (cyaron.tests.compare_test.TestCompare.test_file_input)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\tests\compare_test.py", line 109, in test_file_input
    Compare.program("python correct.py", std_program="python std.py", input=io, grader="NOIPStyle")
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\compare.py", line 174, in program
    std = get_std()
          ^^^^^^^^^
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\compare.py", line 161, in get_std
    subprocess.check_output(
  File "C:\Python312\Lib\subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'python std.py' returned non-zero exit status 3.

======================================================================
ERROR: test_fulltext_program (cyaron.tests.compare_test.TestCompare.test_fulltext_program)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\tests\compare_test.py", line 80, in test_fulltext_program
    Compare.program("python correct.py", "python incorrect.py", std=io, input=io, grader="FullText")
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\compare.py", line 225, in program
    [x for x in map(do, programs)]
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\compare.py", line 202, in do
    subprocess.check_output(
  File "C:\Python312\Lib\subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'python correct.py' returned non-zero exit status 3.

======================================================================
ERROR: test_output_gen_time_limit_exceeded (cyaron.tests.io_test.TestIO.test_output_gen_time_limit_exceeded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\tests\io_test.py", line 83, in test_output_gen_time_limit_exceeded
    test.output_gen("python long_time.py", time_limit=1)
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\io.py", line 261, in output_gen
    subprocess.check_call(
  File "C:\Python312\Lib\subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'python long_time.py' returned non-zero exit status 3.

======================================================================
ERROR: test_output_gen_time_limit_not_exceeded (cyaron.tests.io_test.TestIO.test_output_gen_time_limit_not_exceeded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\tests\io_test.py", line 96, in test_output_gen_time_limit_not_exceeded
    test.output_gen("python short_time.py", time_limit=1)
  File "D:\Admin\Desktop\IDE\github\cyaron\cyaron\io.py", line 261, in output_gen
    subprocess.check_call(
  File "C:\Python312\Lib\subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'python short_time.py' returned non-zero exit status 3.

----------------------------------------------------------------------
Ran 41 tests in 1.904s

FAILED (errors=4)

附程序:

#include <bits/stdc++.h>
using namespace std;

int main(int argc, const char* argv[]) {
	for (int i = 0; i < argc; ++i)
		cerr << argv[i] << endl;
	return 3;
}

@weilycoder
Copy link
Contributor Author

weilycoder commented Dec 15, 2024

Linux 下,使用 python3(我只能用虚拟环境,因为 Linux 自带的 python 不能下 xeger):

Details

weily@weily:~/cyaron$ ./venv/bin/python3 unit_test.py
test_concurrent (cyaron.tests.compare_test.TestCompare.test_concurrent) ... ('/home/weily/cyaron/venv/bin/python3', 'test2.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test4.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test6.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test0.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test1.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test3.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test7.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test5.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test8.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test12.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test13.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test10.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test9.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test11.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test14.py'): Correct 
('/home/weily/cyaron/venv/bin/python3', 'test15.py'): Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
None: Correct 
ok
test_file_input (cyaron.tests.compare_test.TestCompare.test_file_input) ... /bin/sh: 1: python: not found
ERROR
test_fulltext_program (cyaron.tests.compare_test.TestCompare.test_fulltext_program) ... /bin/sh: 1: python: not found
ERROR
test_noipstyle_correct (cyaron.tests.compare_test.TestCompare.test_noipstyle_correct) ... ok
test_noipstyle_incorrect (cyaron.tests.compare_test.TestCompare.test_noipstyle_incorrect) ... ok
test_timeout (cyaron.tests.compare_test.TestCompare.test_timeout) ... ok
test_DAG (cyaron.tests.graph_test.TestGraph.test_DAG) ... ok
test_DAG_boundary (cyaron.tests.graph_test.TestGraph.test_DAG_boundary) ... ok
test_DAG_without_loop (cyaron.tests.graph_test.TestGraph.test_DAG_without_loop) ... ok
test_GraphMatrix (cyaron.tests.graph_test.TestGraph.test_GraphMatrix) ... ok
test_forest (cyaron.tests.graph_test.TestGraph.test_forest) ... ok
test_repeated_edges (cyaron.tests.graph_test.TestGraph.test_repeated_edges) ... ok
test_self_loop (cyaron.tests.graph_test.TestGraph.test_self_loop) ... ok
test_tree_connected (cyaron.tests.graph_test.TestGraph.test_tree_connected) ... ok
test_undirected_graph (cyaron.tests.graph_test.TestGraph.test_undirected_graph) ... ok
test_create_files_prefix_id (cyaron.tests.io_test.TestIO.test_create_files_prefix_id) ... ok
test_create_files_simple (cyaron.tests.io_test.TestIO.test_create_files_simple) ... ok
test_create_files_without_prefix_id (cyaron.tests.io_test.TestIO.test_create_files_without_prefix_id) ... ok
test_init_overload (cyaron.tests.io_test.TestIO.test_init_overload) ... ok
test_make_dirs (cyaron.tests.io_test.TestIO.test_make_dirs) ... ok
test_output_clear_content (cyaron.tests.io_test.TestIO.test_output_clear_content) ... ok
test_output_clear_content_with_position (cyaron.tests.io_test.TestIO.test_output_clear_content_with_position) ... ok
test_output_gen (cyaron.tests.io_test.TestIO.test_output_gen) ... ok
test_output_gen_time_limit_exceeded (cyaron.tests.io_test.TestIO.test_output_gen_time_limit_exceeded) ... /bin/sh: 1: python: not found
ERROR
test_output_gen_time_limit_not_exceeded (cyaron.tests.io_test.TestIO.test_output_gen_time_limit_not_exceeded) ... /bin/sh: 1: python: not found
ERROR
test_write_stuff (cyaron.tests.io_test.TestIO.test_write_stuff) ... ok
test_convex_hull (cyaron.tests.polygon_test.TestPolygon.test_convex_hull) ... ok
test_perimeter_area (cyaron.tests.polygon_test.TestPolygon.test_perimeter_area) ... ok
test_simple_polygon (cyaron.tests.polygon_test.TestPolygon.test_simple_polygon) ... ok
test_func_get_many (cyaron.tests.sequence_test.TestSequence.test_func_get_many) ... ok
test_func_get_one (cyaron.tests.sequence_test.TestSequence.test_func_get_one) ... ok
test_simple_get_many (cyaron.tests.sequence_test.TestSequence.test_simple_get_many) ... ok
test_simple_get_one (cyaron.tests.sequence_test.TestSequence.test_simple_get_one) ... ok
test_random_paragraph (cyaron.tests.str_test.TestString.test_random_paragraph) ... ok
test_random_regular (cyaron.tests.str_test.TestString.test_random_regular) ... ok
test_random_sentence (cyaron.tests.str_test.TestString.test_random_sentence) ... ok
test_random_word (cyaron.tests.str_test.TestString.test_random_word) ... ok
test_random_word_from_dict (cyaron.tests.str_test.TestString.test_random_word_from_dict) ... ok
test_float_vector (cyaron.tests.vector_test.TestVector.test_float_vector) ... ok
test_repeatable_vector (cyaron.tests.vector_test.TestVector.test_repeatable_vector) ... ok
test_unique_vector (cyaron.tests.vector_test.TestVector.test_unique_vector) ... ok

======================================================================
ERROR: test_file_input (cyaron.tests.compare_test.TestCompare.test_file_input)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/weily/cyaron/cyaron/tests/compare_test.py", line 109, in test_file_input
    Compare.program("python correct.py", std_program="python std.py", input=io, grader="NOIPStyle")
  File "/home/weily/cyaron/cyaron/compare.py", line 174, in program
    std = get_std()
          ^^^^^^^^^
  File "/home/weily/cyaron/cyaron/compare.py", line 161, in get_std
    subprocess.check_output(
  File "/usr/lib/python3.12/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'python std.py' returned non-zero exit status 127.

======================================================================
ERROR: test_fulltext_program (cyaron.tests.compare_test.TestCompare.test_fulltext_program)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/weily/cyaron/cyaron/tests/compare_test.py", line 80, in test_fulltext_program
    Compare.program("python correct.py", "python incorrect.py", std=io, input=io, grader="FullText")
  File "/home/weily/cyaron/cyaron/compare.py", line 225, in program
    [x for x in map(do, programs)]
  File "/home/weily/cyaron/cyaron/compare.py", line 202, in do
    subprocess.check_output(
  File "/usr/lib/python3.12/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'python correct.py' returned non-zero exit status 127.

======================================================================
ERROR: test_output_gen_time_limit_exceeded (cyaron.tests.io_test.TestIO.test_output_gen_time_limit_exceeded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/weily/cyaron/cyaron/tests/io_test.py", line 83, in test_output_gen_time_limit_exceeded
    test.output_gen("python long_time.py", time_limit=1)
  File "/home/weily/cyaron/cyaron/io.py", line 261, in output_gen
    subprocess.check_call(
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'python long_time.py' returned non-zero exit status 127.

======================================================================
ERROR: test_output_gen_time_limit_not_exceeded (cyaron.tests.io_test.TestIO.test_output_gen_time_limit_not_exceeded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/weily/cyaron/cyaron/tests/io_test.py", line 96, in test_output_gen_time_limit_not_exceeded
    test.output_gen("python short_time.py", time_limit=1)
  File "/home/weily/cyaron/cyaron/io.py", line 261, in output_gen
    subprocess.check_call(
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'python short_time.py' returned non-zero exit status 127.

----------------------------------------------------------------------
Ran 41 tests in 1.735s

FAILED (errors=4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants