Do not permit empty python namespace names

This commit is contained in:
2026-04-08 13:28:48 +02:00
parent 2cac1727e1
commit 286ba68c34
3 changed files with 3 additions and 6 deletions
@@ -37,6 +37,7 @@ class PythonNamespace:
self.name = name self.name = name
class PythonPackageNamespace(PythonNamespace): class PythonPackageNamespace(PythonNamespace):
''' '''
A subclass of ``PythonNamespace`` for python package namespaces. A subclass of ``PythonNamespace`` for python package namespaces.
@@ -4,11 +4,9 @@ import pytest
class StrSubclass(str): ... class StrSubclass(str): ...
@pytest.mark.parametrize('namespace,expected_name', [ @pytest.mark.parametrize('namespace,expected_name', [
(PythonModuleNamespace(''), ''),
(PythonModuleNamespace(' '), ' '),
(PythonModuleNamespace('a'), 'a'), (PythonModuleNamespace('a'), 'a'),
(PythonModuleNamespace('1'), '1'), (PythonModuleNamespace('1'), '1'),
(PythonModuleNamespace(StrSubclass('')), StrSubclass('')), (PythonModuleNamespace(StrSubclass('a')), StrSubclass('a')),
]) ])
def test_PythonModuleNamespace_name_attribute(namespace, expected_name): def test_PythonModuleNamespace_name_attribute(namespace, expected_name):
assert namespace.name == expected_name assert namespace.name == expected_name
@@ -4,11 +4,9 @@ import pytest
class StrSubclass(str): ... class StrSubclass(str): ...
@pytest.mark.parametrize('namespace,expected_name', [ @pytest.mark.parametrize('namespace,expected_name', [
(PythonNamespace(''), ''),
(PythonNamespace(' '), ' '),
(PythonNamespace('a'), 'a'), (PythonNamespace('a'), 'a'),
(PythonNamespace('1'), '1'), (PythonNamespace('1'), '1'),
(PythonNamespace(StrSubclass('')), StrSubclass('')), (PythonNamespace(StrSubclass('a')), StrSubclass('a')),
]) ])
def test_PythonNamespace_name_attribute(namespace, expected_name): def test_PythonNamespace_name_attribute(namespace, expected_name):
assert namespace.name == expected_name assert namespace.name == expected_name