Skip to content

Commit

Permalink
fix: unitest issues
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram committed Dec 18, 2024
1 parent 40f3771 commit f14659c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions openedx/core/lib/xblock_pipeline/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.contrib.staticfiles.storage import FileSystemStorage
from django.core.files.storage import Storage
from django.utils import timezone
from importlib.resources import files, isdir, exists, listdir
from importlib.resources import files, exists, listdir
from xblock.core import XBlock

from openedx.core.lib.xblock_utils import xblock_resource_pkg
Expand Down Expand Up @@ -54,15 +54,15 @@ def listdir(self, path):
Lists the directories beneath the specified path.
"""
directories = []
files = []
dir_files = []
for item in listdir(self.module, os.path.join(self.base_dir, path)):
__, file_extension = os.path.splitext(item)
if file_extension not in [".py", ".pyc", ".scss"]:
if isdir(self.module, os.path.join(self.base_dir, path, item)):
if os.path.isdir(os.path.join(self.base_dir, path, item)):
directories.append(item)
else:
files.append(item)
return directories, files
dir_files.append(item)
return directories, dir_files

def open(self, name, mode='rb'):
"""
Expand Down
16 changes: 7 additions & 9 deletions xmodule/x_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,16 +855,14 @@ def templates(cls):
@classmethod
def get_template_dir(cls): # lint-amnesty, pylint: disable=missing-function-docstring
if getattr(cls, 'template_dir_name', None):
dirname = files(__name__).joinpath('templates', cls.template_dir_name)
if not dirname.is_dir():
log.warning(
"No resource directory {dir} found when loading {cls_name} templates".format(
dir=f'templates/{cls.template_dir_name}',
cls_name=cls.__name__,
)
)
dirname = os.path.join('templates', cls.template_dir_name)
if not os.path.isdir(os.path.join(os.path.dirname(__file__), dirname)):
log.warning("No resource directory {dir} found when loading {cls_name} templates".format(
dir=dirname,
cls_name=cls.__name__,
))
return None
return f'templates/{cls.template_dir_name}'
return dirname
return None

@classmethod
Expand Down

0 comments on commit f14659c

Please sign in to comment.