Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception assertions' content #243

Merged
merged 1 commit into from Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/api_test.py
Expand Up @@ -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():
Expand All @@ -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)
)


Expand Down
8 changes: 4 additions & 4 deletions tests/ingest_test.py
Expand Up @@ -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():
Expand All @@ -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',
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/model_test.py
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions tests/spec_test.py
Expand Up @@ -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)