diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ analysis/ build/ dist/ +.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/loader/dir/tests/test_converters.py b/swh/loader/dir/tests/test_converters.py --- a/swh/loader/dir/tests/test_converters.py +++ b/swh/loader/dir/tests/test_converters.py @@ -39,11 +39,11 @@ super().tearDownClass() def test_format_to_minutes(self): - self.assertEquals(converters.format_to_minutes('+0100'), 60) - self.assertEquals(converters.format_to_minutes('-0200'), -120) - self.assertEquals(converters.format_to_minutes('+1250'), 12*60+50) - self.assertEquals(converters.format_to_minutes('+0000'), 0) - self.assertEquals(converters.format_to_minutes('-0000'), 0) + self.assertEqual(converters.format_to_minutes('+0100'), 60) + self.assertEqual(converters.format_to_minutes('-0200'), -120) + self.assertEqual(converters.format_to_minutes('+1250'), 12*60+50) + self.assertEqual(converters.format_to_minutes('+0000'), 0) + self.assertEqual(converters.format_to_minutes('-0000'), 0) def test_annotated_tag_to_release(self): # given @@ -110,7 +110,7 @@ actual_revision = converters.commit_to_revision(commit) # then - self.assertEquals(actual_revision, expected_revision) + self.assertEqual(actual_revision, expected_revision) def test_commit_to_revision_with_parents(self): """Commit with existing parents should not lose information @@ -158,4 +158,4 @@ actual_revision = converters.commit_to_revision(commit) # then - self.assertEquals(actual_revision, expected_revision) + self.assertEqual(actual_revision, expected_revision) diff --git a/swh/loader/dir/tests/test_loader.py b/swh/loader/dir/tests/test_loader.py --- a/swh/loader/dir/tests/test_loader.py +++ b/swh/loader/dir/tests/test_loader.py @@ -4,14 +4,13 @@ # See top-level LICENSE file for more information import os - -from nose.plugins.attrib import attr +import pytest from swh.loader.core.tests import BaseLoaderTest, LoaderNoStorage from swh.loader.dir.loader import DirLoader -@attr('fs') +@pytest.mark.fs class BaseDirLoaderTest(BaseLoaderTest): def setUp(self, archive_name='sample-folder.tgz'): super().setUp(archive_name=archive_name, @@ -116,15 +115,15 @@ branch_name=b'master') # then - self.assertEquals(len(objects), 5, - "5 obj types: con, dir, rev, rel, snap") - self.assertEquals(len(objects['content']), 8, - "8 contents: 3 files + 5 links") - self.assertEquals(len(objects['directory']), 6, - "6 directories: 5 subdirs + 1 empty") - self.assertEquals(len(objects['revision']), 1, "synthetic revision") - self.assertEquals(len(objects['release']), 1, "synthetic release") - self.assertEquals(len(objects['snapshot']), 1, "snapshot") + self.assertEqual(len(objects), 5, + "5 obj types: con, dir, rev, rel, snap") + self.assertEqual(len(objects['content']), 8, + "8 contents: 3 files + 5 links") + self.assertEqual(len(objects['directory']), 6, + "6 directories: 5 subdirs + 1 empty") + self.assertEqual(len(objects['revision']), 1, "synthetic revision") + self.assertEqual(len(objects['release']), 1, "synthetic release") + self.assertEqual(len(objects['snapshot']), 1, "snapshot") TEST_CONFIG = { @@ -219,14 +218,11 @@ self.assertCountRevisions(1) actual_revision = self.state('revision')[0] - self.assertEquals(actual_revision['synthetic'], - True) - self.assertEquals(actual_revision['parents'], - []) - self.assertEquals(actual_revision['type'], - 'tar') - self.assertEquals(actual_revision['message'], - b'swh-loader-dir: synthetic revision message') + self.assertEqual(actual_revision['synthetic'], True) + self.assertEqual(actual_revision['parents'], []) + self.assertEqual(actual_revision['type'], 'tar') + self.assertEqual(actual_revision['message'], + b'swh-loader-dir: synthetic revision message') self.assertCountReleases(0) self.assertCountSnapshots(1) diff --git a/tox.ini b/tox.ini new file mode 100644 --- /dev/null +++ b/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist=flake8,py3 + +[testenv:py3] +deps = + .[testing] + pytest-cov +commands = + pytest --cov=swh --cov-branch {posargs} + +[testenv:flake8] +skip_install = true +deps = + flake8 +commands = + {envpython} -m flake8