Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ docs/_build
.DS_Store
.*.un~

# project
.idea

# git

*.orig
Expand Down
2 changes: 2 additions & 0 deletions pywps/inout/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def extension(self, extension):
def same_as(self, frmt):
"""Check input frmt, if it seems to be the same as self
"""
if not isinstance(frmt, Format):
return False
return all([frmt.mime_type == self.mime_type,
frmt.encoding == self.encoding,
frmt.schema == self.schema])
Expand Down
17 changes: 17 additions & 0 deletions tests/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ def test_getformat(self):

self.assertTrue(frmt.same_as(frmt2))

def test_format_equal_types(self):
"""Test that equality check returns the expected bool and doesn't raise
when types mismatch.
"""
frmt = get_format('GML')
self.assertTrue(isinstance(frmt, Format))
try:
res = frmt.same_as("GML") # not a Format type
except AssertionError:
self.fail("Comparing a format to another type should not raise")
except Exception:
self.fail("Unexpected error, test failed for unknown reason")
self.assertFalse(res, "Equality check with other type should be False")

frmt_other = get_format('GML')
self.assertTrue(frmt == frmt_other, "Same formats should return True")

def test_json_out(self):
"""Test json export
"""
Expand Down