Skip to content

Commit

Permalink
Merge pull request #243 from macisamuele/maci-fix-tests
Browse files Browse the repository at this point in the history
Fix exception assertions' content
  • Loading branch information
macisamuele committed Aug 27, 2019
2 parents c13bcd3 + eff92af commit 49cd380
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
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)

0 comments on commit 49cd380

Please sign in to comment.