diff --git a/tox.ini b/tox.ini index 9a862f698573c864921ab9998d1a6a8a07978126..b87f6e8140dbc431d0b190301dbfa1125e4b8ede 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,6 @@ skip_missing_interpreters = true [testenv] deps = . - pynose pytest pytest-cov mypy diff --git a/unittests/test_concrete_property.py b/unittests/test_concrete_property.py index e70668f02aab12762a342f035a974f708652ae69..6a55dcf99c258b4c0eb000588e7fea7eb4a4c68f 100644 --- a/unittests/test_concrete_property.py +++ b/unittests/test_concrete_property.py @@ -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(): diff --git a/unittests/test_connection.py b/unittests/test_connection.py index ca36a71680f8e13ac9114b9ab0bff0b6a96ea4c3..a4903fb3a4f7d12d7b87a5a30cbf643e48d5fe23 100644 --- a/unittests/test_connection.py +++ b/unittests/test_connection.py @@ -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")) diff --git a/unittests/test_connection_utils.py b/unittests/test_connection_utils.py index 6a95fffa2f5f3dbfb302e035deee2f24fab9acf5..4f114783eebed88ac3d4755ff3dc224b6c5feed3 100644 --- a/unittests/test_connection_utils.py +++ b/unittests/test_connection_utils.py @@ -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 ( diff --git a/unittests/test_file.py b/unittests/test_file.py index dd974cb176ca69e2ffb065b5de185611e528e815..c1093cdd26b71bd8f1d48e98dd224df956f629f8 100644 --- a/unittests/test_file.py +++ b/unittests/test_file.py @@ -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" diff --git a/unittests/test_record_type.py b/unittests/test_record_type.py index 594f9c647997d68cccdcccc56eaab482cd694c74..87a3d22964d1e452fe74f2f5c19edb149382162a 100644 --- a/unittests/test_record_type.py +++ b/unittests/test_record_type.py @@ -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"