From b7998d44025b6e2523955d506646272e6690cdac Mon Sep 17 00:00:00 2001 From: mprahl Date: Mon, 5 Feb 2018 16:14:15 -0500 Subject: [PATCH] Remove the need for nose and solely rely on pytest --- module_build_service/config.py | 3 +-- test-requirements.txt | 1 - tests/test_scm.py | 29 +++++++++++++---------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/module_build_service/config.py b/module_build_service/config.py index 81aa06d9..f8d45de6 100644 --- a/module_build_service/config.py +++ b/module_build_service/config.py @@ -83,8 +83,7 @@ def init_config(app): if 'MBS_CONFIG_SECTION' in app.request.environ: config_section = app.request.environ['MBS_CONFIG_SECTION'] # TestConfiguration shall only be used for running tests, otherwise... - if any(['nosetests' in arg or 'noserunner.py' in arg or 'py.test' in arg or 'pytest' in arg - for arg in sys.argv]): + if any(['py.test' in arg or 'pytest' in arg for arg in sys.argv]): config_section = 'TestConfiguration' from conf import config config_module = config diff --git a/test-requirements.txt b/test-requirements.txt index 203a70f9..0f6e5d48 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,6 @@ copr mock -nose pytest vcrpy flake8 diff --git a/tests/test_scm.py b/tests/test_scm.py index 52fce294..59ac93a5 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -24,8 +24,8 @@ import os import shutil import tempfile +import pytest from mock import patch -from nose.tools import raises import module_build_service.scm from module_build_service.errors import ValidationError, UnprocessableEntity @@ -85,11 +85,9 @@ class TestSCMModule: scm.checkout(self.tempdir) scm.verify() - @raises(UnprocessableEntity) def test_verify_unknown_branch(self): - scm = module_build_service.scm.SCM(repo_path, "unknown") - scm.checkout(self.tempdir) - scm.verify() + with pytest.raises(UnprocessableEntity): + module_build_service.scm.SCM(repo_path, "unknown") def test_verify_commit_in_branch(self): target = '7035bd33614972ac66559ac1fdd019ff6027ad21' @@ -97,31 +95,30 @@ class TestSCMModule: scm.checkout(self.tempdir) scm.verify() - @raises(ValidationError) def test_verify_commit_not_in_branch(self): target = '7035bd33614972ac66559ac1fdd019ff6027ad21' scm = module_build_service.scm.SCM(repo_path + "?#" + target, "master") scm.checkout(self.tempdir) - scm.verify() + with pytest.raises(ValidationError): + scm.verify() - @raises(UnprocessableEntity) def test_verify_unknown_hash(self): target = '7035bd33614972ac66559ac1fdd019ff6027ad22' scm = module_build_service.scm.SCM(repo_path + "?#" + target, "master") - scm.checkout(self.tempdir) - scm.verify() + with pytest.raises(UnprocessableEntity): + scm.checkout(self.tempdir) - @raises(UnprocessableEntity) def test_get_module_yaml(self): scm = module_build_service.scm.SCM(repo_path) scm.checkout(self.tempdir) scm.verify() - scm.get_module_yaml() + with pytest.raises(UnprocessableEntity): + scm.get_module_yaml() - @raises(UnprocessableEntity) def test_get_latest_incorrect_component_branch(self): scm = module_build_service.scm.SCM(repo_path) - scm.get_latest('foobar') + with pytest.raises(UnprocessableEntity): + scm.get_latest('foobar') def test_get_latest_component_branch(self): ref = "5481faa232d66589e660cc301179867fb00842c9" @@ -136,10 +133,10 @@ class TestSCMModule: commit = scm.get_latest(ref) assert commit == ref - @raises(UnprocessableEntity) def test_get_latest_incorrect_component_ref(self): scm = module_build_service.scm.SCM(repo_path) - scm.get_latest('15481faa232d66589e660cc301179867fb00842c9') + with pytest.raises(UnprocessableEntity): + scm.get_latest('15481faa232d66589e660cc301179867fb00842c9') @patch.object(module_build_service.scm.SCM, '_run') def test_get_latest_ignore_origin(self, mock_run):