diff --git a/swh/core/tests/test_api.py b/swh/core/tests/test_api.py --- a/swh/core/tests/test_api.py +++ b/swh/core/tests/test_api.py @@ -4,7 +4,6 @@ # See top-level LICENSE file for more information import unittest -from nose.tools import istest import requests_mock from werkzeug.wrappers import BaseResponse @@ -16,7 +15,6 @@ class ApiTest(unittest.TestCase): - @istest def test_server(self): testcase = self nb_endpoint_calls = 0 @@ -46,7 +44,6 @@ self.assertEqual(nb_endpoint_calls, 1) self.assertEqual(b''.join(res.response), b'\xa3egg') - @istest def test_client(self): class TestStorage: @remote_api_endpoint('test_endpoint_url') diff --git a/swh/core/tests/test_config.py b/swh/core/tests/test_config.py --- a/swh/core/tests/test_config.py +++ b/swh/core/tests/test_config.py @@ -3,12 +3,10 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -import tempfile -import unittest import os import shutil - -from nose.tools import istest +import tempfile +import unittest from swh.core import config @@ -100,50 +98,43 @@ os.chmod(cls.perms_broken_file, 0o644) shutil.rmtree(cls.tmpdir) - @istest - def read(self): + def test_read(self): # when res = config.read(self.conffile, self.default_conf) # then self.assertEquals(res, self.parsed_conffile) - @istest - def read_empty_file(self): + def test_read_empty_file(self): # when res = config.read(None, self.default_conf) # then self.assertEquals(res, self.parsed_default_conf) - @istest - def support_non_existing_conffile(self): + def test_support_non_existing_conffile(self): # when res = config.read(self.non_existing_conffile, self.default_conf) # then self.assertEquals(res, self.parsed_default_conf) - @istest - def support_empty_conffile(self): + def test_support_empty_conffile(self): # when res = config.read(self.empty_conffile, self.default_conf) # then self.assertEquals(res, self.parsed_default_conf) - @istest - def raise_on_broken_directory_perms(self): + def test_raise_on_broken_directory_perms(self): with self.assertRaises(PermissionError): config.read(self.file_in_broken_dir, self.default_conf) - @istest - def raise_on_broken_file_perms(self): + def test_raise_on_broken_file_perms(self): with self.assertRaises(PermissionError): config.read(self.perms_broken_file, self.default_conf) - @istest - def merge_default_configs(self): + def test_merge_default_configs(self): # when res = config.merge_default_configs(self.default_conf, self.other_default_conf) @@ -151,8 +142,7 @@ # then self.assertEquals(res, self.full_default_conf) - @istest - def priority_read_nonexist_conf(self): + def test_priority_read_nonexist_conf(self): # when res = config.priority_read([self.non_existing_conffile, self.conffile], self.default_conf) @@ -160,8 +150,7 @@ # then self.assertEquals(res, self.parsed_conffile) - @istest - def priority_read_conf_nonexist_empty(self): + def test_priority_read_conf_nonexist_empty(self): # when res = config.priority_read([ self.conffile, @@ -172,8 +161,7 @@ # then self.assertEquals(res, self.parsed_conffile) - @istest - def priority_read_empty_conf_nonexist(self): + def test_priority_read_empty_conf_nonexist(self): # when res = config.priority_read([ self.empty_conffile, @@ -184,8 +172,7 @@ # then self.assertEquals(res, self.parsed_default_conf) - @istest - def swh_config_paths(self): + def test_swh_config_paths(self): res = config.swh_config_paths('foo/bar.ini') self.assertEqual(res, [ @@ -194,8 +181,7 @@ '/etc/softwareheritage/foo/bar.ini', ]) - @istest - def prepare_folder(self): + def test_prepare_folder(self): # given conf = {'path1': os.path.join(self.tmpdir, 'path1'), 'path2': os.path.join(self.tmpdir, 'path2', 'depth1')} diff --git a/swh/core/tests/test_logger.py b/swh/core/tests/test_logger.py --- a/swh/core/tests/test_logger.py +++ b/swh/core/tests/test_logger.py @@ -7,13 +7,11 @@ import os import unittest -from nose.tools import istest from nose.plugins.attrib import attr from swh.core.logger import PostgresHandler from swh.core.tests.db_testing import SingleDbTestFixture - TEST_DIR = os.path.dirname(os.path.abspath(__file__)) SQL_DIR = os.path.join(TEST_DIR, '../../../sql') @@ -34,8 +32,7 @@ logging.shutdown() super().tearDown() - @istest - def log(self): + def test_log(self): self.logger.info('notice', extra={'swh_type': 'test entry', 'swh_data': 42}) self.logger.warn('warning') diff --git a/swh/core/tests/test_serializers.py b/swh/core/tests/test_serializers.py --- a/swh/core/tests/test_serializers.py +++ b/swh/core/tests/test_serializers.py @@ -3,16 +3,19 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -import arrow import datetime import json import unittest from uuid import UUID -from nose.tools import istest +import arrow -from swh.core.serializers import SWHJSONDecoder, SWHJSONEncoder -from swh.core.serializers import msgpack_dumps, msgpack_loads +from swh.core.serializers import ( + SWHJSONDecoder, + SWHJSONEncoder, + msgpack_dumps, + msgpack_loads +) class Serializers(unittest.TestCase): @@ -56,27 +59,22 @@ self.generator = (i for i in range(5)) self.gen_lst = list(range(5)) - @istest - def round_trip_json(self): + def test_round_trip_json(self): data = json.dumps(self.data, cls=SWHJSONEncoder) self.assertEqual(self.data, json.loads(data, cls=SWHJSONDecoder)) - @istest - def encode_swh_json(self): + def test_encode_swh_json(self): data = json.dumps(self.data, cls=SWHJSONEncoder) self.assertEqual(self.encoded_data, json.loads(data)) - @istest - def round_trip_msgpack(self): + def test_round_trip_msgpack(self): data = msgpack_dumps(self.data) self.assertEqual(self.data, msgpack_loads(data)) - @istest - def generator_json(self): + def test_generator_json(self): data = json.dumps(self.generator, cls=SWHJSONEncoder) self.assertEqual(self.gen_lst, json.loads(data, cls=SWHJSONDecoder)) - @istest - def generator_msgpack(self): + def test_generator_msgpack(self): data = msgpack_dumps(self.generator) self.assertEqual(self.gen_lst, msgpack_loads(data)) diff --git a/swh/core/tests/test_utils.py b/swh/core/tests/test_utils.py --- a/swh/core/tests/test_utils.py +++ b/swh/core/tests/test_utils.py @@ -5,15 +5,12 @@ import unittest -from nose.tools import istest - from swh.core import utils class UtilsLib(unittest.TestCase): - @istest - def grouper(self): + def test_grouper(self): # given actual_data = utils.grouper((i for i in range(0, 9)), 2) @@ -32,8 +29,7 @@ self.assertEqual(out, [[9, 8, 7, 6], [5, 4, 3, 2], [1]]) - @istest - def backslashescape_errors(self): + def test_backslashescape_errors(self): raw_data_err = b'abcd\x80' with self.assertRaises(UnicodeDecodeError): raw_data_err.decode('utf-8', 'strict') @@ -55,8 +51,7 @@ b'abcdef\\xa3', ) - @istest - def encode_with_unescape(self): + def test_encode_with_unescape(self): valid_data = '\\x01020304\\x00' valid_data_encoded = b'\x01020304\x00' @@ -65,8 +60,7 @@ utils.encode_with_unescape(valid_data) ) - @istest - def encode_with_unescape_invalid_escape(self): + def test_encode_with_unescape_invalid_escape(self): invalid_data = 'test\\abcd' with self.assertRaises(ValueError) as exc: @@ -75,8 +69,7 @@ self.assertIn('invalid escape', exc.exception.args[0]) self.assertIn('position 4', exc.exception.args[0]) - @istest - def decode_with_escape(self): + def test_decode_with_escape(self): backslashes = b'foo\\bar\\\\baz' backslashes_escaped = 'foo\\\\bar\\\\\\\\baz' @@ -109,8 +102,7 @@ utils.decode_with_escape(valid_utf8_nul), ) - @istest - def commonname(self): + def test_commonname(self): # when actual_commonname = utils.commonname('/some/where/to/', '/some/where/to/go/to')