@@ -23,10 +23,13 @@ def pytest_collect_file(parent, path):
2323 return
2424
2525 config = parent .config
26- masks = config .getini ('cpp_files' ) or DEFAULT_MASKS
27-
28- test_args = config .getini (_ARGUMENTS ) or ( )
26+ masks = config .getini ('cpp_files' )
27+ test_args = config . getini ( 'cpp_arguments' )
28+ cpp_ignore_py_files = config .getini ('cpp_ignore_py_files' )
2929
30+ # don't attempt to check *.py files even if they were given as explicit arguments
31+ if cpp_ignore_py_files and path .fnmatch ('*.py' ):
32+ return
3033 if not parent .session .isinitpath (path ):
3134 for pat in masks :
3235 if path .fnmatch (pat ):
@@ -39,13 +42,18 @@ def pytest_collect_file(parent, path):
3942
4043
4144def pytest_addoption (parser ):
42- parser .addini ("cpp_files" , type = "args" ,
43- default = DEFAULT_MASKS ,
44- help = "glob-style file patterns for C++ test module discovery" )
45- parser .addini (_ARGUMENTS ,
46- type = 'args' ,
47- default = '' ,
48- help = 'Additional arguments for test executables' )
45+ parser .addini ('cpp_files' ,
46+ type = 'args' ,
47+ default = DEFAULT_MASKS ,
48+ help = "glob-style file patterns for C++ test module discovery" )
49+ parser .addini ('cpp_arguments' ,
50+ type = 'args' ,
51+ default = (),
52+ help = 'additional arguments for test executables' )
53+ parser .addini ('cpp_ignore_py_files' ,
54+ type = 'bool' ,
55+ default = True ,
56+ help = 'ignore *.py files that otherwise match "cpp_files" patterns' )
4957
5058
5159class CppFile (pytest .File ):
0 commit comments