Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testmon/testmon_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_file(self, filename):
self.cache[filename] = Module(
source_code=code,
mtime=fs_mtime,
ext=filename.rsplit(".", 1)[1],
ext=filename.rsplit(".", 1)[1] if "." in filename else "",
fs_fsha=fsha,
filename=filename,
rootdir=self.rootdir,
Expand Down
13 changes: 13 additions & 0 deletions tests/test_process_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,16 @@ def test_noncached_get_files_shas(testdir):
testdir.run("git", "commit", "-m", "Initial commit")

assert isinstance(noncached_get_files_shas(testdir.tmpdir.strpath), dict)


def test_get_file_extensionless(tmp_path):
"""Test that SourceTree.get_file handles files without extensions."""
extensionless = tmp_path / "Dockerfile"
extensionless.write_text("FROM python:3.10\n")

source_tree = SourceTree(str(tmp_path))
module = source_tree.get_file("Dockerfile")

assert module is not None
assert module.ext == ""
assert len(module.blocks) == 1