diff --git a/docs/xblock-tutorial/getting_started/prereqs.rst b/docs/xblock-tutorial/getting_started/prereqs.rst index a91510cdd..01a564563 100644 --- a/docs/xblock-tutorial/getting_started/prereqs.rst +++ b/docs/xblock-tutorial/getting_started/prereqs.rst @@ -16,7 +16,7 @@ Python 3.11 *********** To run the a virtual environment and the XBlock SDK, and to build an XBlock, -you must have Python 3.1 installed on your computer. +you must have Python 3.11 installed on your computer. `Download Python`_ for your operating system and follow the installation instructions. diff --git a/xblock/core.py b/xblock/core.py index 578d8ad60..f2f06ac85 100644 --- a/xblock/core.py +++ b/xblock/core.py @@ -157,10 +157,10 @@ def open_local_resource(cls, uri): if "/." in uri: raise DisallowedFileError("Only safe file names are allowed: %r" % uri) - return cls.open_resource(uri) + return cls._open_resource(uri) @classmethod - def open_resource(cls, uri): + def _open_resource(cls, uri): return importlib.resources.files(inspect.getmodule(cls).__package__).joinpath( os.path.join(cls.resources_dir, uri) ).open('rb') diff --git a/xblock/test/test_core.py b/xblock/test/test_core.py index 4abaa241a..8a888a210 100644 --- a/xblock/test/test_core.py +++ b/xblock/test/test_core.py @@ -962,7 +962,7 @@ class UnloadableXBlock(XBlock): resources_dir = None def stub_open_resource(self, uri): - """Act like xblock.core.Blocklike.open_resource, for testing.""" + """Act like xblock.core.Blocklike._open_resource, for testing.""" return "!" + uri + "!" @ddt.data( @@ -975,7 +975,7 @@ def stub_open_resource(self, uri): ) def test_open_good_local_resource(self, uri): loadable = self.LoadableXBlock(None, scope_ids=Mock()) - with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource): + with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource): assert loadable.open_local_resource(uri) == "!" + uri + "!" assert loadable.open_local_resource(uri.encode('utf-8')) == "!" + uri + "!" @@ -989,7 +989,7 @@ def test_open_good_local_resource(self, uri): ) def test_open_good_local_resource_binary(self, uri): loadable = self.LoadableXBlock(None, scope_ids=Mock()) - with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource): + with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource): assert loadable.open_local_resource(uri) == "!" + uri.decode('utf-8') + "!" @ddt.data( @@ -1003,7 +1003,7 @@ def test_open_good_local_resource_binary(self, uri): ) def test_open_bad_local_resource(self, uri): loadable = self.LoadableXBlock(None, scope_ids=Mock()) - with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource): + with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource): msg_pattern = ".*: %s" % re.escape(repr(uri)) with pytest.raises(DisallowedFileError, match=msg_pattern): loadable.open_local_resource(uri) @@ -1019,7 +1019,7 @@ def test_open_bad_local_resource(self, uri): ) def test_open_bad_local_resource_binary(self, uri): loadable = self.LoadableXBlock(None, scope_ids=Mock()) - with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource): + with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource): msg = ".*: %s" % re.escape(repr(uri.decode('utf-8'))) with pytest.raises(DisallowedFileError, match=msg): loadable.open_local_resource(uri) @@ -1042,7 +1042,7 @@ def test_open_bad_local_resource_binary(self, uri): def test_open_local_resource_with_no_resources_dir(self, uri): unloadable = self.UnloadableXBlock(None, scope_ids=Mock()) - with patch('xblock.core.Blocklike.open_resource', self.stub_open_resource): + with patch('xblock.core.Blocklike._open_resource', self.stub_open_resource): msg = "not configured to serve local resources" with pytest.raises(DisallowedFileError, match=msg): unloadable.open_local_resource(uri)