Skip to content
Snippets Groups Projects
Commit b3e815be authored by Nicolas Dandrimont's avatar Nicolas Dandrimont
Browse files

Rename test methods to test_ to allow collection by pytest

Part of T1261
parent 8f5b10b3
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,6 @@
import abc
import unittest
from nose.tools import istest
from swh.lister.core.abstractattribute import AbstractAttribute
......@@ -38,7 +36,6 @@ class GoodSubclass(BaseClass):
class TestAbstractAttributes(unittest.TestCase):
@istest
def test_aa(self):
with self.assertRaises(TypeError):
BaseClass()
......@@ -60,7 +57,6 @@ class TestAbstractAttributes(unittest.TestCase):
self.assertEqual(gsc.v3, 'baz')
self.assertEqual(gsc.v4, 'qux')
@istest
def test_aa_docstrings(self):
self.assertEqual(BaseClass.v1.__doc__, AbstractAttribute.__doc__)
self.assertEqual(BaseClass.v2.__doc__, AbstractAttribute.__doc__)
......
......@@ -8,9 +8,8 @@ from unittest import TestCase
from unittest.mock import Mock, patch
import requests_mock
from testing.postgresql import Postgresql
from nose.tools import istest
from sqlalchemy import create_engine
from testing.postgresql import Postgresql
from swh.lister.core.abstractattribute import AbstractAttribute
......@@ -119,7 +118,6 @@ class HttpListerTesterBase(abc.ABC):
self.response = fl.safely_issue_request(self.first_index)
return self.response
@istest
def test_is_within_bounds(self, http_mocker):
fl = self.get_fl()
self.assertFalse(fl.is_within_bounds(1, 2, 3))
......@@ -141,14 +139,12 @@ class HttpListerTesterBase(abc.ABC):
with self.assertRaises(TypeError):
fl.is_within_bounds("A:B", "A::B", None)
@istest
def test_api_request(self, http_mocker):
http_mocker.get(self.test_re, text=self.mock_limit_twice_response)
with patch.object(time, 'sleep', wraps=time.sleep) as sleepmock:
self.get_api_response()
self.assertEqual(sleepmock.call_count, 2)
@istest
def test_repos_list(self, http_mocker):
http_mocker.get(self.test_re, text=self.mock_response)
li = self.get_fl().transport_response_simplified(
......@@ -157,7 +153,6 @@ class HttpListerTesterBase(abc.ABC):
self.assertIsInstance(li, list)
self.assertEqual(len(li), self.entries_per_page)
@istest
def test_model_map(self, http_mocker):
http_mocker.get(self.test_re, text=self.mock_response)
fl = self.get_fl()
......@@ -177,7 +172,6 @@ class HttpListerTesterBase(abc.ABC):
fl.db_inject_repo = Mock(return_value=fl.MODEL())
fl.disable_deleted_repo_tasks = Mock(return_value=None)
@istest
def test_fetch_none_nodb(self, http_mocker):
http_mocker.get(self.test_re, text=self.mock_response)
fl = self.get_fl()
......@@ -187,7 +181,6 @@ class HttpListerTesterBase(abc.ABC):
fl.run(min_bound=1, max_bound=1) # stores no results
@istest
def test_fetch_one_nodb(self, http_mocker):
http_mocker.get(self.test_re, text=self.mock_response)
fl = self.get_fl()
......@@ -197,7 +190,6 @@ class HttpListerTesterBase(abc.ABC):
fl.run(min_bound=self.first_index, max_bound=self.first_index)
@istest
def test_fetch_multiple_pages_nodb(self, http_mocker):
http_mocker.get(self.test_re, text=self.mock_response)
fl = self.get_fl()
......@@ -216,7 +208,6 @@ class HttpListerTester(HttpListerTesterBase, abc.ABC):
last_index = AbstractAttribute('Last index in good_api_response')
@requests_mock.Mocker()
@istest
def test_fetch_multiple_pages_yesdb(self, http_mocker):
http_mocker.get(self.test_re, text=self.mock_response)
initdb_args = Postgresql.DEFAULT_SETTINGS['initdb_args']
......
......@@ -4,10 +4,9 @@
import unittest
from nose.tools import istest
from sqlalchemy import Column, Integer
from swh.lister.core.models import ModelBase, IndexingModelBase
from swh.lister.core.models import IndexingModelBase, ModelBase
class BadSubclass1(ModelBase):
......@@ -52,7 +51,6 @@ class IndexingGoodSubclass(IndexingModelBase):
class TestModel(unittest.TestCase):
@istest
def test_model_instancing(self):
with self.assertRaises(TypeError):
ModelBase()
......@@ -72,7 +70,6 @@ class TestModel(unittest.TestCase):
self.assertEqual(gsc.__tablename__, 'foo')
self.assertEqual(gsc.uid, 'uid')
@istest
def test_indexing_model_instancing(self):
with self.assertRaises(TypeError):
IndexingModelBase()
......
......@@ -4,11 +4,10 @@
import re
import unittest
from datetime import datetime, timedelta
from swh.lister.gitlab.lister import GitLabLister
from swh.lister.core.tests.test_lister import HttpListerTesterBase
from swh.lister.gitlab.lister import GitLabLister
class GitLabListerTester(HttpListerTesterBase, unittest.TestCase):
......
......@@ -4,23 +4,19 @@
import unittest
from nose.tools import istest
from swh.lister import utils
class UtilsTest(unittest.TestCase):
@istest
def split_range(self):
def test_split_range(self):
actual_ranges = list(utils.split_range(14, 5))
self.assertEqual(actual_ranges, [(0, 5), (5, 10), (10, 14)])
actual_ranges = list(utils.split_range(19, 10))
self.assertEqual(actual_ranges, [(0, 10), (10, 19)])
@istest
def split_range_errors(self):
def test_split_range_errors(self):
with self.assertRaises(TypeError):
list(utils.split_range(None, 1))
......
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