diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ dist/ *.egg-info version.txt +.tox/ diff --git a/requirements-test.txt b/requirements-test.txt --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1 +1 @@ -nose +pytest diff --git a/swh/archiver/db.py b/swh/archiver/db.py --- a/swh/archiver/db.py +++ b/swh/archiver/db.py @@ -165,14 +165,17 @@ def content_archive_add_from_temp(self, cur=None): """Add new content archive entries from temporary table. - Use from archiver.storage module:: - db.mktemp_content_archive(cur) - # copy data over to the temp table - db.copy_to([{'colname': id0}, {'colname': id1}], - 'tmp_cache_content', - ['colname'], cur) - # insert into the main table - db.add_content_archive_from_temp(cur) + Use from archiver.storage module: + + .. code-block:: python + + db.mktemp_content_archive(cur) + # copy data over to the temp table + db.copy_to([{'colname': id0}, {'colname': id1}], + 'tmp_cache_content', + ['colname'], cur) + # insert into the main table + db.add_content_archive_from_temp(cur) """ pass diff --git a/swh/archiver/tests/test_archiver.py b/swh/archiver/tests/test_archiver.py --- a/swh/archiver/tests/test_archiver.py +++ b/swh/archiver/tests/test_archiver.py @@ -10,7 +10,7 @@ import tempfile import unittest -from nose.plugins.attrib import attr +import pytest from swh.archiver import (ArchiverWithRetentionPolicyDirector, ArchiverWithRetentionPolicyWorker) @@ -22,7 +22,7 @@ from swh.archiver.tests import SQL_DIR -@attr('db') +@pytest.mark.db class TestArchiver(SingleDbTestFixture, unittest.TestCase): """ Test the objstorage archiver. """ @@ -177,7 +177,7 @@ self.archiver.run() # now the content should be present on remote objstorage remote_data = self.dest_storage.get(obj_id) - self.assertEquals(obj_data, remote_data) + self.assertEqual(obj_data, remote_data) def test_archive_present_content(self): """ A content that is not 'missing' shouldn't be archived. diff --git a/swh/archiver/tests/test_checker.py b/swh/archiver/tests/test_checker.py --- a/swh/archiver/tests/test_checker.py +++ b/swh/archiver/tests/test_checker.py @@ -7,7 +7,7 @@ import tempfile import unittest -from nose.plugins.attrib import attr +import pytest from swh.archiver.checker import RepairContentChecker from swh.model import hashutil @@ -29,7 +29,7 @@ raise ObjNotFoundError(obj_id) -@attr('fs') +@pytest.mark.fs class TestRepairChecker(unittest.TestCase): """ Test the content integrity checker """ diff --git a/tox.ini b/tox.ini new file mode 100644 --- /dev/null +++ b/tox.ini @@ -0,0 +1,17 @@ +[tox] +envlist=flake8,py3 + +[testenv:py3] +deps = + .[testing] + pifpaf + pytest-cov +commands = + pifpaf run postgresql -- pytest --cov=swh --cov-branch {posargs} + +[testenv:flake8] +skip_install = true +deps = + flake8 +commands = + {envpython} -m flake8