Skip to content
Merged
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
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ Unreleased

*

[2.0.1] - 2025-02-05
**********************************************

Changed
=======

* **Replaced `pkg_resources` with `importlib.resources`**
- `pkg_resources` (from `setuptools`) is deprecated and may be removed in future Python versions.
- Now using `importlib.resources`, the recommended alternative for managing package resources.
- This improves performance and ensures better compatibility with modern Python versions.

[2.0.0] - 2025-01-23
**********************************************

Expand Down
2 changes: 1 addition & 1 deletion flow_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Init for main Flow-Control XBlock
"""
from .flow import FlowCheckPointXblock
__version__ = '2.0.0'
__version__ = '2.0.1'
5 changes: 2 additions & 3 deletions flow_control/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
either display the unit's content or take an alternative action """

import logging
import pkg_resources
from importlib.resources import files as importlib_files
import re

from functools import reduce
Expand All @@ -24,8 +24,7 @@

def load(path):
"""Handy helper for getting resources from our kit."""
data = pkg_resources.resource_string(__name__, path)
return data.decode("utf8")
return importlib_files(__package__).joinpath(path).read_text(encoding="utf-8")


def _actions_generator(block): # pylint: disable=unused-argument
Expand Down
16 changes: 8 additions & 8 deletions flow_control/tests/test_flowcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ddt
import unittest

from mock import MagicMock, patch
from mock import MagicMock, patch, mock_open
# from xblock.core import XBlock
from xblock.field_data import DictFieldData
from flow_control.flow import FlowCheckPointXblock
Expand Down Expand Up @@ -85,13 +85,13 @@ def test_operators_generator(self):
self.assertEqual(operators, operators_allowed)

def test_load(self):
"""
It should return the corresponding resource
"""
path_mock = MagicMock()
with patch('pkg_resources.resource_string') as my_patch:
load(path_mock)
my_patch.assert_called_once_with('flow_control.flow', path_mock)
"""It should return the corresponding resource"""
path_mock = "test_resource.txt"
mock_content = "mocked content"

with patch("pathlib.Path.open", mock_open(read_data=mock_content)):
result = load(path_mock)
self.assertEqual(result, mock_content)

@ddt.data(
'course-v1:Course+course+course',
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.0.0
current_version = 2.0.1
commit = True
tag = True

Expand Down