From eff92af90b981d64498dd737dd8ab55f56889730 Mon Sep 17 00:00:00 2001 From: Samuele Maci Date: Mon, 26 Aug 2019 11:40:33 +0200 Subject: [PATCH] Fix exception assertions' content --- tests/api_test.py | 6 +++--- tests/ingest_test.py | 8 ++++---- tests/model_test.py | 4 ++-- tests/spec_test.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/api_test.py b/tests/api_test.py index 129bebb..0dfd802 100644 --- a/tests/api_test.py +++ b/tests/api_test.py @@ -43,9 +43,9 @@ def test_proper_error_on_missing_resource_listing(): 'tests/sample_schemas/missing_resource_listing/api_docs.json'), ) assert( - 'tests/sample_schemas/missing_resource_listing/' in str(exc) + 'tests/sample_schemas/missing_resource_listing/' in str(exc.value) ) - assert 'must be named {0}'.format(API_DOCS_FILENAME) in str(exc) + assert 'must be named {0}'.format(API_DOCS_FILENAME) in str(exc.value) def test_proper_error_on_missing_api_declaration(): @@ -55,7 +55,7 @@ def test_proper_error_on_missing_api_declaration(): ) assert ( 'tests/sample_schemas/missing_api_declaration/missing.json' - in str(exc) + in str(exc.value) ) diff --git a/tests/ingest_test.py b/tests/ingest_test.py index 3595566..ec55ee8 100644 --- a/tests/ingest_test.py +++ b/tests/ingest_test.py @@ -26,8 +26,8 @@ def test_proper_error_on_missing_resource_listing(): filename = 'tests/sample_schemas/missing_resource_listing/api_docs.json' with pytest.raises(ResourceListingNotFoundError) as exc: _load_resource_listing(filename) - assert filename in str(exc) - assert 'must be named {0}'.format(API_DOCS_FILENAME) in str(exc) + assert filename in str(exc.value) + assert 'must be named {0}'.format(API_DOCS_FILENAME) in str(exc.value) def test_proper_error_on_missing_api_declaration(): @@ -36,7 +36,7 @@ def test_proper_error_on_missing_api_declaration(): {'sample_resource': 'fake/sample_resource.json'}, 'fake', ) - assert 'fake/sample_resource.json' in str(exc) + assert 'fake/sample_resource.json' in str(exc.value) @mock.patch('pyramid_swagger.ingest.build_http_handlers', @@ -100,7 +100,7 @@ def test_generate_resource_listing_with_existing_listing(): with pytest.raises(ResourceListingGenerationError) as exc: generate_resource_listing('tests/sample_schemas/good_app/', listing) - assert 'Generating a listing would override' in str(exc) + assert 'Generating a listing would override' in str(exc.value) @mock.patch('pyramid_swagger.ingest.generate_resource_listing', autospec=True) diff --git a/tests/model_test.py b/tests/model_test.py index f3a23ca..f4a2dfc 100644 --- a/tests/model_test.py +++ b/tests/model_test.py @@ -63,8 +63,8 @@ def test_swagger_schema_for_request_not_found(schema): method="GET" ), ) - assert '/does_not_exist' in str(excinfo) - assert 'Could not find ' in str(excinfo) + assert '/does_not_exist' in str(excinfo.value) + assert 'Could not find ' in str(excinfo.value) def test_partial_path_match(): diff --git a/tests/spec_test.py b/tests/spec_test.py index 1bf89c5..3e4a81b 100644 --- a/tests/spec_test.py +++ b/tests/spec_test.py @@ -25,5 +25,5 @@ def test_proper_error_on_missing_api_declaration(): resource_listing = simplejson.load(f) validate_swagger_schema(dir_path, resource_listing) - assert os.path.basename(dir_path) in str(exc) - assert os.path.basename('missing.json') in str(exc) + assert os.path.basename(dir_path) in str(exc.value) + assert os.path.basename('missing.json') in str(exc.value)