@@ -66,6 +66,20 @@ def main() -> None:
6666 main()
6767"""
6868
69+ TESTS_MAIN_PY_WITH_STDLIB = rb"""\
70+ # verify-helper: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_B
71+ from library.imported import solve
72+ import os
73+
74+ def main() -> None:
75+ x = int(input())
76+ ans = solve(x)
77+ print(ans)
78+
79+ if __name__ == "__main__":
80+ main()
81+ """
82+
6983
7084class TestPythonVerification (unittest .TestCase ):
7185 """TestPythonListDependencies has end-to-end tests for the verification of Python files.
@@ -88,3 +102,23 @@ def test_separated_dir(self) -> None:
88102 with open (timestamps_path ) as fh :
89103 timestamps = json .load (fh )
90104 self .assertEqual (list (timestamps .keys ()), [str (pathlib .Path ('tests' , 'main.py' ))])
105+
106+ def test_separated_dir_with_stdlib (self ) -> None :
107+ """`test_separated_dir_with_stdlib` is a test for the case when the library files exist at the separate directory of the test file.
108+ In this test, main.py has an import of a module in stdlib.
109+ """
110+
111+ files = {
112+ pathlib .Path ('library' , '__init__.py' ): b"" ,
113+ pathlib .Path ('library' , 'imported.py' ): LIBRARY_IMPORTED_PY ,
114+ pathlib .Path ('tests' , 'main.py' ): TESTS_MAIN_PY_WITH_STDLIB ,
115+ }
116+ path = pathlib .Path ('tests' , 'main.py' )
117+ with tests .utils .load_files_pathlib (files ) as tempdir :
118+ with tests .utils .chdir (tempdir ):
119+ timestamps_path = tempdir / 'timestamps.json'
120+ with onlinejudge_verify .marker .VerificationMarker (json_path = timestamps_path , use_git_timestamp = False ) as marker :
121+ self .assertEqual (verify .main ([path ], marker = marker ).failed_test_paths , [])
122+ with open (timestamps_path ) as fh :
123+ timestamps = json .load (fh )
124+ self .assertEqual (list (timestamps .keys ()), [str (pathlib .Path ('tests' , 'main.py' ))])
0 commit comments