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
3 changes: 1 addition & 2 deletions luigi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

import atexit
import datetime
import importlib
import json
import logging
import os
Expand Down Expand Up @@ -157,7 +156,7 @@ def initialize(self, scheduler):
self._scheduler = scheduler

def get_template_path(self):
return importlib.resources.files("templates").name
return os.path.join(os.path.dirname(__file__), "templates")


class AllRunHandler(BaseTaskHistoryHandler):
Expand Down
13 changes: 13 additions & 0 deletions test/server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,19 @@ def test_get_no_metrics(self):
patched_write.assert_not_called()


def test_get_template_path_returns_existing_directory():
"""Regression test for https://github.com/spotify/luigi/issues/3415.

The returned path must point to the luigi/templates directory that
tornado uses to render task-history pages.
"""
handler = luigi.server.BaseTaskHistoryHandler(tornado.web.Application(), mock.MagicMock(), scheduler=mock.MagicMock())
path = handler.get_template_path()
assert os.path.isdir(path), f"get_template_path() returned non-existent directory: {path!r}"
assert os.path.basename(path) == "templates"
assert os.path.isfile(os.path.join(path, "recent.html"))


class FromUtcTest(unittest.TestCase):
def test_with_microseconds(self):
"""Test parsing UTC time string with microseconds"""
Expand Down
Loading