Merge branch 'bugfix/13' into dev
ID: 13
Type: bugfix
Title: fix unit tests for urllib PkgHandler
Status: done
Priority: high
Created: 2025-06-21
Description: change of issue 12 wasn't properly reflected in urllib PkgHandler
unit tests
This commit is contained in:
commit
b6a24de08c
2 changed files with 21 additions and 18 deletions
2
TODO
2
TODO
|
|
@ -189,7 +189,7 @@ Description: Only bootstrap a package mock with the minimum requirements for a
|
||||||
ID: 13
|
ID: 13
|
||||||
Type: bugfix
|
Type: bugfix
|
||||||
Title: fix unit tests for urllib PkgHandler
|
Title: fix unit tests for urllib PkgHandler
|
||||||
Status: in-progress
|
Status: done
|
||||||
Priority: high
|
Priority: high
|
||||||
Created: 2025-06-21
|
Created: 2025-06-21
|
||||||
Description: change of issue 12 wasn't properly reflected in urllib PkgHandler
|
Description: change of issue 12 wasn't properly reflected in urllib PkgHandler
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import urllib.request
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from byteb4rb1e.testing.pytest.decorators import run_in_subprocess_once
|
from byteb4rb1e.testing.pytest.decorators import run_in_subprocess_once
|
||||||
from byteb4rb1e.testing.pytest.fixtures import mock_pkg
|
from byteb4rb1e.testing.pytest.fixtures import mock_system_site_package_dir
|
||||||
from byteb4rb1e.utils.urllib.request import PkgHandler
|
from byteb4rb1e.utils.urllib.request import PkgHandler
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ class TestPkgHandler:
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
@run_in_subprocess_once()
|
@run_in_subprocess_once()
|
||||||
def test_text(self, mock_pkg):
|
def test_text(self, mock_system_site_package_dir):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
_opener: urllib.request.OpenerDirector = urllib.request.build_opener(
|
_opener: urllib.request.OpenerDirector = urllib.request.build_opener(
|
||||||
|
|
@ -22,9 +22,8 @@ class TestPkgHandler:
|
||||||
|
|
||||||
dummy_data = 'Hello'
|
dummy_data = 'Hello'
|
||||||
|
|
||||||
mock_pkg('foobarpkg', {
|
pkg_dir = mock_system_site_package_dir('foobarpkg')
|
||||||
'data.txt': dummy_data
|
(pkg_dir / 'data.txt').write_text(dummy_data)
|
||||||
})
|
|
||||||
|
|
||||||
result = _opener.open('pkg://foobarpkg/data.txt').readline()
|
result = _opener.open('pkg://foobarpkg/data.txt').readline()
|
||||||
|
|
||||||
|
|
@ -33,7 +32,7 @@ class TestPkgHandler:
|
||||||
|
|
||||||
|
|
||||||
@run_in_subprocess_once()
|
@run_in_subprocess_once()
|
||||||
def test_bytes(self, mock_pkg):
|
def test_bytes(self, mock_system_site_package_dir):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
_opener: urllib.request.OpenerDirector = urllib.request.build_opener(
|
_opener: urllib.request.OpenerDirector = urllib.request.build_opener(
|
||||||
|
|
@ -42,9 +41,8 @@ class TestPkgHandler:
|
||||||
|
|
||||||
dummy_data = b'foobar123'
|
dummy_data = b'foobar123'
|
||||||
|
|
||||||
mock_pkg('foobarpkg', {
|
pkg_dir = mock_system_site_package_dir('foobarpkg')
|
||||||
'data.bin': dummy_data
|
(pkg_dir / 'data.bin').write_bytes(dummy_data)
|
||||||
})
|
|
||||||
|
|
||||||
result = _opener.open('pkg://foobarpkg/data.bin').readline()
|
result = _opener.open('pkg://foobarpkg/data.bin').readline()
|
||||||
|
|
||||||
|
|
@ -53,7 +51,7 @@ class TestPkgHandler:
|
||||||
|
|
||||||
|
|
||||||
@run_in_subprocess_once()
|
@run_in_subprocess_once()
|
||||||
def test_subdir(self, mock_pkg):
|
def test_subdir(self, mock_system_site_package_dir):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
_opener: urllib.request.OpenerDirector = urllib.request.build_opener(
|
_opener: urllib.request.OpenerDirector = urllib.request.build_opener(
|
||||||
|
|
@ -62,9 +60,12 @@ class TestPkgHandler:
|
||||||
|
|
||||||
dummy_data = 'foobar123'
|
dummy_data = 'foobar123'
|
||||||
|
|
||||||
mock_pkg('foobarpkg', {
|
pkg_dir = mock_system_site_package_dir('foobarpkg')
|
||||||
'foo/bar/data.txt': dummy_data
|
|
||||||
})
|
dummy_file = (pkg_dir / 'foo' / 'bar' / 'data.txt')
|
||||||
|
|
||||||
|
dummy_file.parent.mkdir(parents=True)
|
||||||
|
dummy_file.write_text(dummy_data)
|
||||||
|
|
||||||
result = _opener.open('pkg://foobarpkg/foo/bar/data.txt').readline()
|
result = _opener.open('pkg://foobarpkg/foo/bar/data.txt').readline()
|
||||||
|
|
||||||
|
|
@ -72,7 +73,7 @@ class TestPkgHandler:
|
||||||
|
|
||||||
|
|
||||||
@run_in_subprocess_once()
|
@run_in_subprocess_once()
|
||||||
def test_nested_module(self, mock_pkg):
|
def test_nested_module(self, mock_system_site_package_dir):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
_opener: urllib.request.OpenerDirector = urllib.request.build_opener(
|
_opener: urllib.request.OpenerDirector = urllib.request.build_opener(
|
||||||
|
|
@ -81,9 +82,11 @@ class TestPkgHandler:
|
||||||
|
|
||||||
dummy_data = 'foobar123'
|
dummy_data = 'foobar123'
|
||||||
|
|
||||||
mock_pkg('foo.bar.pkg', {
|
pkg_dir = mock_system_site_package_dir('foo.bar.pkg')
|
||||||
'dummy/data.txt': dummy_data
|
dummy_file = (pkg_dir / 'dummy' / 'data.txt')
|
||||||
})
|
|
||||||
|
dummy_file.parent.mkdir(parents=True)
|
||||||
|
dummy_file.write_text(dummy_data)
|
||||||
|
|
||||||
result = _opener.open('pkg://foo.bar.pkg/dummy/data.txt').readline()
|
result = _opener.open('pkg://foo.bar.pkg/dummy/data.txt').readline()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue