diff --git a/coverage/python.py b/coverage/python.py index 089c27ea6..057cd6061 100644 --- a/coverage/python.py +++ b/coverage/python.py @@ -244,9 +244,6 @@ def should_be_python(self) -> bool: # Anything named *.py* should be Python. if ext.startswith(".py"): return True - # A file with no extension should be Python. - if not ext: - return True # Everything else is probably not Python. return False diff --git a/tests/test_filereporter.py b/tests/test_filereporter.py index c36fa013b..b273d6193 100644 --- a/tests/test_filereporter.py +++ b/tests/test_filereporter.py @@ -102,3 +102,10 @@ def test_zipfile(self) -> None: z1z1 = PythonFileReporter(zip1.zip1) assert z1.source() == "" assert "# My zip file!" in z1z1.source().splitlines() + + def test_python_extensions(self) -> None: + f1 = PythonFileReporter("afile.py") + f2 = PythonFileReporter("Makefile") + + assert f1.should_be_python() + assert not f2.should_be_python()