@@ -65,24 +65,23 @@ def check_stubs() -> None:
6565 allowed = {"METADATA.toml" , "README" , "README.md" , "README.rst" , "@tests" }
6666 assert_consistent_filetypes (dist , kind = ".pyi" , allowed = allowed )
6767
68+ tests_dir = dist / "@tests"
69+ if tests_dir .exists () and tests_dir .is_dir ():
70+ py_files_present = bool ([file for file in tests_dir .iterdir () if file .suffix == ".py" ])
71+ assert not py_files_present , (
72+ "Test-case files must be in an `@tests/test_cases/` directory, not in the `@tests/` directory"
73+ )
74+
6875
6976def check_test_cases () -> None :
70- for package_name , testcase_dir in get_all_testcase_directories ():
77+ for _ , testcase_dir in get_all_testcase_directories ():
7178 assert_consistent_filetypes (testcase_dir , kind = ".py" , allowed = {"README.md" }, allow_nonidentifier_filenames = True )
7279 bad_test_case_filename = 'Files in a `test_cases` directory must have names starting with "check_"; got "{}"'
7380 for file in testcase_dir .rglob ("*.py" ):
7481 assert file .stem .startswith ("check_" ), bad_test_case_filename .format (file )
7582 with open (file , encoding = "UTF-8" ) as f :
7683 lines = {line .strip () for line in f }
7784 assert "from __future__ import annotations" in lines , "Test-case files should use modern typing syntax where possible"
78- if package_name != "stdlib" :
79- pyright_setting_not_enabled_msg = (
80- f'Third-party test-case file "{ file } " must have '
81- f'"# pyright: reportUnnecessaryTypeIgnoreComment=true" '
82- f"at the top of the file"
83- )
84- has_pyright_setting_enabled = "# pyright: reportUnnecessaryTypeIgnoreComment=true" in lines
85- assert has_pyright_setting_enabled , pyright_setting_not_enabled_msg
8685
8786
8887def check_no_symlinks () -> None :
0 commit comments