Skip to content
Snippets Groups Projects
Commit 78a0bcdf authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Remove nose dependency from testing

Only nose.tools was used, which can easily be replaced with one-liners and pytest.raises
parent e70687c3
No related branches found
No related tags found
1 merge request!143Release 0.15.0
......@@ -4,7 +4,6 @@ skip_missing_interpreters = true
[testenv]
deps = .
pynose
pytest
pytest-cov
mypy
......
......@@ -28,9 +28,16 @@ from linkahead import configure_connection
from linkahead.common.models import _ConcreteProperty
from linkahead.connection.mockup import MockUpServerConnection
# pylint: disable=missing-docstring
from nose.tools import assert_equal as eq
from nose.tools import assert_is_not_none as there
from nose.tools import assert_true as tru
def eq(a,b):
assert a == b
def there(a):
assert a is not None
def tru(a):
assert a
from pytest import raises
def setup_module():
......
......@@ -39,11 +39,17 @@ from linkahead.connection.mockup import (MockUpResponse, MockUpServerConnection,
from linkahead.connection.utils import make_uri_path, quote, urlencode
from linkahead.exceptions import (ConfigurationError, LoginFailedError,
LinkAheadConnectionError)
from nose.tools import assert_equal as eq
from nose.tools import assert_false as falz
from nose.tools import assert_is_not_none as there
from nose.tools import assert_raises as raiz
from nose.tools import assert_true as tru
def eq(a,b):
assert a == b
def there(a):
assert a is not None
def tru(a):
assert a
from pytest import raises
......@@ -74,11 +80,11 @@ def test_urlencode():
eq(urlencode({'key1': 'val1'}), 'key1=val1')
eq(urlencode({'keynoval': None}), 'keynoval=')
eq(urlencode({'kèy': 'välüe'}), 'k%C3%A8y=v%C3%A4l%C3%BCe')
with raiz(AttributeError):
with raises(AttributeError) as exc_info:
urlencode({bytes('asdf', 'utf-8'): 'asdf'})
with raiz(AttributeError):
with raises(AttributeError) as exc_info:
urlencode({'asdf': bytes('asdf', 'utf-8')})
with raiz(AttributeError):
with raises(AttributeError) as exc_info:
urlencode({None: 'asdf'})
......@@ -138,10 +144,11 @@ def test_configure_connection_bad_url():
def test_connection_interface():
with raiz(TypeError) as cm:
with raises(TypeError) as cm:
CaosDBServerConnection()
tru(cm.exception.args[0].startswith(
"Can't instantiate abstract class CaosDBServerConnection"))
assert "Can't instantiate abstract class CaosDBServerConnection" in str(cm.value)
tru(hasattr(CaosDBServerConnection, "request"))
tru(hasattr(CaosDBServerConnection.request, "__call__"))
......@@ -151,10 +158,10 @@ def test_connection_interface():
def test_use_mockup_implementation():
with raiz(RuntimeError) as rerr:
with raises(RuntimeError) as rerr:
execute_query("FIND Something")
print(rerr.exception.args[0])
eq(rerr.exception.args[0],
print(str(rerr.value))
eq(str(rerr.value),
"No response for this request - GET: Entity?query=FIND%20Something")
......@@ -219,9 +226,9 @@ def test_resources_list():
def test_request_basics():
connection = test_init_connection()
tru(hasattr(connection, "request"))
with raiz(RuntimeError) as cm:
with raises(RuntimeError) as cm:
connection.request(method="GET", path="asdf")
eq(cm.exception.args[0], "No response for this request - GET: asdf")
eq(str(cm.value), "No response for this request - GET: asdf")
connection = test_resources_list()
there(connection.request(method="GET", path="asdf"))
......
......@@ -25,9 +25,18 @@
# pylint: disable=missing-docstring
from __future__ import unicode_literals, print_function
from pytest import raises
from nose.tools import (assert_equal as eq, assert_raises as raiz, assert_true
as tru, assert_is_not_none as there, assert_false as
falz)
def eq(a,b):
assert a == b
def there(a):
assert a is not None
def tru(a):
assert a
from pytest import raises
from linkahead.exceptions import ConfigurationError, LoginFailedError
from linkahead.connection.utils import parse_auth_token, auth_token_to_cookie
from linkahead.connection.connection import (
......
......@@ -25,13 +25,10 @@
from linkahead import File, Record, configure_connection
from linkahead.connection.mockup import MockUpServerConnection
# pylint: disable=missing-docstring
from nose.tools import assert_equal as eq
from nose.tools import assert_is_not_none as there
from nose.tools import assert_true as tru
def setup_module():
there(File)
assert File is not None
configure_connection(url="unittests", username="testuser",
password_method="plain",
password="testpassword", timeout=200,
......@@ -39,12 +36,12 @@ def setup_module():
def hat(obj, attr):
tru(hasattr(obj, attr))
assert hasattr(obj, attr)
def test_is_record():
file_ = File()
tru(isinstance(file_, Record))
assert isinstance(file_, Record)
def test_instance_variable():
......@@ -57,4 +54,4 @@ def test_instance_variable():
def test_role():
file_ = File()
eq(file_.role, "File")
assert file_.role == "File"
......@@ -25,13 +25,9 @@
from linkahead import Entity, RecordType, configure_connection
from linkahead.connection.mockup import MockUpServerConnection
# pylint: disable=missing-docstring
from nose.tools import assert_equal as eq
from nose.tools import assert_is_not_none as there
from nose.tools import assert_true as tru
def setup_module():
there(RecordType)
assert RecordType is not None
configure_connection(url="unittests", username="testuser",
password_method="plain",
password="testpassword", timeout=200,
......@@ -39,14 +35,14 @@ def setup_module():
def hat(obj, attr):
tru(hasattr(obj, attr))
assert hasattr(obj, attr)
def test_is_entity():
recty = RecordType()
tru(isinstance(recty, Entity))
assert isinstance(recty, Entity)
def test_role():
recty = RecordType()
eq(recty.role, "RecordType")
assert recty.role == "RecordType"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment