From ca374da8a71d22948bf2b9ac5e2f1d2bdd37d8b9 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Fri, 10 May 2024 19:11:50 -0700 Subject: [PATCH] py.test -> pytest, move py3 versions fwd Signed-off-by: Dan Mick --- chacra/tests/controllers/repos/test_repos.py | 64 ++++++++++---------- chacra/tests/controllers/test_binaries.py | 42 ++++++------- tox.ini | 4 +- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/chacra/tests/controllers/repos/test_repos.py b/chacra/tests/controllers/repos/test_repos.py index cb1b439..1b0e43d 100644 --- a/chacra/tests/controllers/repos/test_repos.py +++ b/chacra/tests/controllers/repos/test_repos.py @@ -1,6 +1,6 @@ import os import pecan -import py.test +import pytest from chacra.models import Project, Repo, Binary from chacra.compat import b_ from chacra import asynch @@ -8,7 +8,7 @@ class TestRepoApiController(object): - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -28,7 +28,7 @@ def test_repo_archs(self, session, url): result = session.app.get(url) assert result.json['archs'] == ['x86_64'] - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/repo/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/repo/'] @@ -48,7 +48,7 @@ def test_repo_endpoint_deb(self, session, url): result = session.app.get(url) assert b_("deb") in result.body - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/centos/7/repo/', '/repos/foobar/firefly/head/centos/7/flavors/default/repo/'] @@ -70,7 +70,7 @@ def test_repo_endpoint_rpm(self, session, url): assert b_("noarch") in result.body assert b_("SRPMS") in result.body - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar-opensuse/firefly/head/opensuse/15.1/repo/', '/repos/foobar-opensuse/firefly/head/opensuse/15.1/flavors/default/repo/'] @@ -92,7 +92,7 @@ def test_repo_endpoint_rpm_opensuse_sle(self, session, url): assert b_("noarch") not in result.body assert b_("SRPMS") not in result.body - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -115,7 +115,7 @@ def test_repo_exists(self, session, url): assert result.json["ref"] == "firefly" assert result.json["sha1"] == "head" - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -138,7 +138,7 @@ def test_repo_exists_no_path(self, session, url): assert result.json["sha1"] == "head" - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -158,7 +158,7 @@ def test_repo_is_not_queued(self, session, url): assert result.status_int == 200 assert result.json["is_queued"] is False - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -178,7 +178,7 @@ def test_repo_is_not_updating(self, session, url): assert result.status_int == 200 assert result.json["is_updating"] is False - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -198,7 +198,7 @@ def test_repo_type(self, session, url): assert result.status_int == 200 assert result.json["type"] is None - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/precise/', '/repos/foobar/firefly/head/ubuntu/precise/flavors/default/'] @@ -217,7 +217,7 @@ def test_distro_version_does_not_exist(self, session, url): result = session.app.get(url, expect_errors=True) assert result.status_int == 404 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/centos/trusty/', '/repos/foobar/firefly/head/centos/trusty/flavors/default/'] @@ -236,7 +236,7 @@ def test_distro_does_not_exist(self, session, url): result = session.app.get(url, expect_errors=True) assert result.status_int == 404 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/hammer/head/ubuntu/trusty/', '/repos/foobar/hammer/head/ubuntu/trusty/flavors/default/'] @@ -255,7 +255,7 @@ def test_ref_does_not_exist(self, session, url): result = session.app.get('/repos/foobar/hammer/head/ubuntu/trusty/', expect_errors=True) assert result.status_int == 404 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/sha1/ubuntu/trusty/', '/repos/foobar/firefly/sha1/ubuntu/trusty/flavors/default/'] @@ -274,7 +274,7 @@ def test_sha1_does_not_exist(self, session, url): result = session.app.get(url, expect_errors=True) assert result.status_int == 404 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -293,7 +293,7 @@ def test_extra_metadata_default(self, session, url): result = session.app.get(url) assert result.json['extra'] == {} - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/extra/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/extra/'] @@ -318,7 +318,7 @@ def test_add_extra_metadata(self, session, url): updated_repo = Repo.get(repo_id) assert updated_repo.extra == {"version": "0.94.8", 'distros': ['precise']} - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -345,7 +345,7 @@ def test_update_single_field(self, session, url): assert updated_repo.distro_version == "precise" assert result.json['distro_version'] == "precise" - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -374,7 +374,7 @@ def test_update_multiple_fields(self, session, url): assert result.json['distro_version'] == "7" assert result.json['distro'] == "centos" - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -401,7 +401,7 @@ def test_update_invalid_fields(self, session, url): updated_repo = Repo.get(repo_id) assert updated_repo.distro == "ubuntu" - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -424,7 +424,7 @@ def test_update_empty_json(self, session, url): ) assert result.status_int == 400 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'] @@ -451,7 +451,7 @@ def test_update_invalid_field_value(self, session, url): class TestRepoCRUDOperations(object): - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/update', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/update'] @@ -477,8 +477,8 @@ def test_update(self, session, tmpdir, url): assert result.json['needs_update'] is True assert result.json['is_queued'] is False - @py.test.mark.dmick - @py.test.mark.parametrize( + @pytest.mark.dmick + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/'], @@ -520,7 +520,7 @@ def test_create(self, session, url): result = session.app.get(url) assert result.json['type'] == 'raw' - @py.test.mark.dmick + @pytest.mark.dmick def test_raw_post_update(self, session, recorder, monkeypatch): pecan.conf.repos_root = '/tmp/root' url = '/repos/foobar/main/head/windows/999/' @@ -550,7 +550,7 @@ def test_raw_post_update(self, session, recorder, monkeypatch): result = session.app.post(url + 'update/') assert fake_post_status.recorder_calls[0]['args'][0] == 'ready' - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/update', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/update'] @@ -569,7 +569,7 @@ def test_update_head(self, session, tmpdir, url): result = session.app.head(url) assert result.status_int == 200 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/recreate', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/recreate'] @@ -591,7 +591,7 @@ def test_recreate(self, session, tmpdir, url): assert result.json['needs_update'] is True assert result.json['is_queued'] is False - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/recreate', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/recreate'] @@ -616,7 +616,7 @@ def test_recreate_and_requeue(self, session, tmpdir, url): assert result.json['needs_update'] is True assert result.json['is_queued'] is False - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/recreate', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/recreate'] @@ -638,7 +638,7 @@ def test_recreate_invalid_path(self, session, tmpdir, url): assert os.path.exists(path) is True assert result.json['needs_update'] is True - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/recreate', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/recreate'] @@ -657,7 +657,7 @@ def test_recreate_head(self, session, tmpdir, url): result = session.app.head(url) assert result.status_int == 200 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/recreate', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/recreate'] @@ -670,7 +670,7 @@ def test_recreate_head_not_found(self, session, tmpdir, url): ) assert result.status_int == 404 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/repos/foobar/firefly/head/ubuntu/trusty/recreate', '/repos/foobar/firefly/head/ubuntu/trusty/flavors/default/recreate'] diff --git a/chacra/tests/controllers/test_binaries.py b/chacra/tests/controllers/test_binaries.py index 239a67a..fe75038 100644 --- a/chacra/tests/controllers/test_binaries.py +++ b/chacra/tests/controllers/test_binaries.py @@ -1,6 +1,6 @@ import os import pecan -import py.test +import pytest from chacra.models import Binary, Project, Repo from chacra.tests import util @@ -72,7 +72,7 @@ def test_same_project_different_archs_should_not_pollute_other_endpoints(self, s class TestBinaryController(object): - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/flavors/default/'] @@ -86,7 +86,7 @@ def test_single_binary_file_creates_resource(self, session, tmpdir, url): ) assert result.status_int == 201 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/flavors/default/'] @@ -104,7 +104,7 @@ def test_put_is_not_allowed(self, session, tmpdir, url): ) assert result.status_int == 405 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_get', [('/binaries/ceph/giant/head/ceph/el7/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/'), @@ -125,7 +125,7 @@ def test_archs_is_not_found(self, session, tmpdir, url_post, url_get): ) assert result.status_int == 404 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_get', [('/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/ceph-9.0.0-0.el6.x86_64.rpm/'), @@ -156,7 +156,7 @@ def test_single_binary_file_can_be_deleted(self, session, tmpdir): result = session.app.get('/binaries/ceph/giant/head/ceph/el6/x86_64/ceph-9.0.0-0.el6.x86_64.rpm/', expect_errors=True) assert result.status_int == 404 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph/giant/head/ceph/el6/x86_64/ceph-9.0.0-0.el6.x86_64.rpm/', '/binaries/ceph/giant/head/ceph/el6/x86_64/flavors/default/ceph-9.0.0-0.el6.x86_64.rpm/'] @@ -175,7 +175,7 @@ def test_binary_file_deletes_object_with_no_path(self, session, url): result = session.app.delete(url, expect_errors=True) assert result.status_int == 204 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph/giant/head/ceph/el6/x86_64/ceph-9.0.0-0.el6.x86_64.rpm/', '/binaries/ceph/giant/head/ceph/el6/x86_64/flavors/default/ceph-9.0.0-0.el6.x86_64.rpm/'] @@ -216,7 +216,7 @@ def test_binary_file_deleted_project_exists(self, session, tmpdir): p = Project.get(1) assert p.name == "ceph" - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_delete', [('/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/ceph-9.0.0-0.el6.x86_64.rpm/'), @@ -258,7 +258,7 @@ def test_binary_file_deleted_repo_exists(self, session, tmpdir): repo = Repo.get(1) assert repo.needs_update - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph/giant/head/ceph/el6/x86_64/ceph-9.0.0-0.el6.x86_64.rpm/', '/binaries/ceph/giant/head/ceph/el6/x86_64/flavors/default/ceph-9.0.0-0.el6.x86_64.rpm/'] @@ -291,7 +291,7 @@ def test_new_binary_upload_creates_model_with_path_forced(self, session, tmpdir) binary = Binary.get(1) assert binary.path.endswith('ceph/giant/head/ceph/el6/x86_64/ceph-9.0.0-0.el6.x86_64.rpm') - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_post_2', [('/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/'), @@ -314,7 +314,7 @@ def test_new_binary_upload_fails_with_existing(self, session, tmpdir, url_post, assert result.status_int == 400 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_post_2', [('/binaries/ceph/giant/head/ceph/el7/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/'), @@ -351,7 +351,7 @@ def test_posting_twice_updates_the_binary(self, session, tmpdir): contents = open(destination).read() assert contents == 'something changed' - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_get', [('/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/'), @@ -368,7 +368,7 @@ def test_binary_tells_what_project_it_belongs_to(self, session, tmpdir, url_post result = response['ceph-9.0.0-0.el6.x86_64.rpm']['project'] assert result == 'ceph' - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_get', [('/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/'), @@ -385,7 +385,7 @@ def test_binary_gets_size_computed(self, session, tmpdir, url_post, url_get): result = response['ceph-9.0.0-0.el6.x86_64.rpm']['size'] assert result == 13 - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_get', [('/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/'), @@ -421,7 +421,7 @@ def test_binary_gets_checksum_computed_when_updated(self, session, tmpdir): result = response['ceph-9.0.0-0.el6.x86_64.rpm']['checksum'] assert result.startswith('a5725e467') - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url_post, url_head', [('/binaries/ceph/giant/head/ceph/el6/x86_64/', '/binaries/ceph/giant/head/ceph/el6/x86_64/'), @@ -440,7 +440,7 @@ def test_head_requests_are_allowed(self, session, tmpdir, url_post, url_head): class TestRelatedProjects(object): - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph-deploy/main/head/centos/6/x86_64/', '/binaries/ceph-deploy/main/head/centos/6/x86_64/flavors/default/'] @@ -463,7 +463,7 @@ def test_marks_nonexsitent_related_project(self, session, tmpdir, url): repo = Repo.filter_by(project=project).first() assert repo.needs_update is True - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph-deploy/main/head/centos/6/x86_64/', '/binaries/ceph-deploy/main/head/centos/6/x86_64/flavors/default/'] @@ -487,7 +487,7 @@ def test_marks_existing_related_project(self, session, tmpdir, url): repo = Repo.filter_by(project=project).first() assert repo.needs_update is True - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph-deploy/main/head/centos/6/x86_64/', '/binaries/ceph-deploy/main/head/centos/6/x86_64/flavors/default/'] @@ -513,7 +513,7 @@ def test_marks_multiple_projects(self, session, tmpdir, url): assert Repo.filter_by(project=ceph_project).first().needs_update is True assert Repo.filter_by(project=rhcs_project).first().needs_update is True - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph-deploy/main/head/centos/6/x86_64/', '/binaries/ceph-deploy/main/head/centos/6/x86_64/flavors/default/'] @@ -538,7 +538,7 @@ def test_marks_nonexsitent_related_project_type(self, session, tmpdir, url): class TestAutomaticRepos(object): # these are not unittests :( - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph-deploy/main/head/centos/6/x86_64/', '/binaries/ceph-deploy/main/head/centos/6/x86_64/flavors/default/'] @@ -571,7 +571,7 @@ def test_skips_marking_needs_update_on_related_repos(self, session, tmpdir, url) repo = Repo.filter_by(project=project).first() assert repo.needs_update is False - @py.test.mark.parametrize( + @pytest.mark.parametrize( 'url', ['/binaries/ceph-deploy/main/head/centos/6/x86_64/', '/binaries/ceph-deploy/main/head/centos/6/x86_64/flavors/default/'] diff --git a/tox.ini b/tox.ini index 3075117..b0e0766 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] -envlist = py35, py36, py37, py38, flake8 +envlist = py{37,38,39,310,311}, flake8 skip_missing_interpreters = true [testenv] deps= pytest WebTest -commands=py.test -v {posargs:chacra/tests} +commands=pytest -v {posargs:chacra/tests} [testenv:flake8] deps=flake8