@@ -65,24 +65,22 @@ 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+ error_message = "Test-case files must be in an `@tests/test_cases/` directory, not in the `@tests/` directory"
72+ assert not py_files_present , error_message
73+
6874
6975def check_test_cases () -> None :
70- for package_name , testcase_dir in get_all_testcase_directories ():
76+ for _ , testcase_dir in get_all_testcase_directories ():
7177 assert_consistent_filetypes (testcase_dir , kind = ".py" , allowed = {"README.md" }, allow_nonidentifier_filenames = True )
7278 bad_test_case_filename = 'Files in a `test_cases` directory must have names starting with "check_"; got "{}"'
7379 for file in testcase_dir .rglob ("*.py" ):
7480 assert file .stem .startswith ("check_" ), bad_test_case_filename .format (file )
7581 with open (file , encoding = "UTF-8" ) as f :
7682 lines = {line .strip () for line in f }
7783 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
8684
8785
8886def check_no_symlinks () -> None :
0 commit comments