Remove qtutils.ensure_not_null
It's not used anymore.
This commit is contained in:
parent
3b1b325711
commit
2c3fcda18e
@ -174,12 +174,6 @@ def ensure_valid(obj):
|
|||||||
raise QtValueError(obj)
|
raise QtValueError(obj)
|
||||||
|
|
||||||
|
|
||||||
def ensure_not_null(obj):
|
|
||||||
"""Ensure a Qt object with an .isNull() method is not null."""
|
|
||||||
if obj.isNull():
|
|
||||||
raise QtValueError(obj, null=True)
|
|
||||||
|
|
||||||
|
|
||||||
def check_qdatastream(stream):
|
def check_qdatastream(stream):
|
||||||
"""Check the status of a QDataStream and raise OSError if it's not ok."""
|
"""Check the status of a QDataStream and raise OSError if it's not ok."""
|
||||||
status_to_str = {
|
status_to_str = {
|
||||||
|
@ -209,48 +209,32 @@ class QtObject:
|
|||||||
return self._null
|
return self._null
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('func_name, obj, raising, exc_reason, exc_str', [
|
@pytest.mark.parametrize('obj, raising, exc_reason, exc_str', [
|
||||||
# ensure_valid, good examples
|
# good examples
|
||||||
('ensure_valid', QtObject(valid=True, null=True), False, None, None),
|
(QtObject(valid=True, null=True), False, None, None),
|
||||||
('ensure_valid', QtObject(valid=True, null=False), False, None, None),
|
(QtObject(valid=True, null=False), False, None, None),
|
||||||
# ensure_valid, bad examples
|
# bad examples
|
||||||
('ensure_valid', QtObject(valid=False, null=True), True, None,
|
(QtObject(valid=False, null=True), True, None, '<QtObject> is not valid'),
|
||||||
'<QtObject> is not valid'),
|
(QtObject(valid=False, null=False), True, None, '<QtObject> is not valid'),
|
||||||
('ensure_valid', QtObject(valid=False, null=False), True, None,
|
(QtObject(valid=False, null=True, error='Test'), True, 'Test',
|
||||||
'<QtObject> is not valid'),
|
'<QtObject> is not valid: Test'),
|
||||||
('ensure_valid', QtObject(valid=False, null=True, error='Test'), True,
|
|
||||||
'Test', '<QtObject> is not valid: Test'),
|
|
||||||
# ensure_not_null, good examples
|
|
||||||
('ensure_not_null', QtObject(valid=True, null=False), False, None, None),
|
|
||||||
('ensure_not_null', QtObject(valid=False, null=False), False, None, None),
|
|
||||||
# ensure_not_null, bad examples
|
|
||||||
('ensure_not_null', QtObject(valid=True, null=True), True, None,
|
|
||||||
'<QtObject> is null'),
|
|
||||||
('ensure_not_null', QtObject(valid=False, null=True), True, None,
|
|
||||||
'<QtObject> is null'),
|
|
||||||
('ensure_not_null', QtObject(valid=False, null=True, error='Test'), True,
|
|
||||||
'Test', '<QtObject> is null: Test'),
|
|
||||||
])
|
])
|
||||||
def test_ensure(func_name, obj, raising, exc_reason, exc_str):
|
def test_ensure_valid(obj, raising, exc_reason, exc_str):
|
||||||
"""Test ensure_valid and ensure_not_null.
|
"""Test ensure_valid.
|
||||||
|
|
||||||
The function is parametrized as they do nearly the same.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
func_name: The name of the function to call.
|
|
||||||
obj: The object to test with.
|
obj: The object to test with.
|
||||||
raising: Whether QtValueError is expected to be raised.
|
raising: Whether QtValueError is expected to be raised.
|
||||||
exc_reason: The expected .reason attribute of the exception.
|
exc_reason: The expected .reason attribute of the exception.
|
||||||
exc_str: The expected string of the exception.
|
exc_str: The expected string of the exception.
|
||||||
"""
|
"""
|
||||||
func = getattr(qtutils, func_name)
|
|
||||||
if raising:
|
if raising:
|
||||||
with pytest.raises(qtutils.QtValueError) as excinfo:
|
with pytest.raises(qtutils.QtValueError) as excinfo:
|
||||||
func(obj)
|
qtutils.ensure_valid(obj)
|
||||||
assert excinfo.value.reason == exc_reason
|
assert excinfo.value.reason == exc_reason
|
||||||
assert str(excinfo.value) == exc_str
|
assert str(excinfo.value) == exc_str
|
||||||
else:
|
else:
|
||||||
func(obj)
|
qtutils.ensure_valid(obj)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('status, raising, message', [
|
@pytest.mark.parametrize('status, raising, message', [
|
||||||
|
Loading…
Reference in New Issue
Block a user