Skip to content

Commit

Permalink
Increase test coverage: Add tests, mark abstract method as no cover
Browse files Browse the repository at this point in the history
  • Loading branch information
victorhahncastell committed Sep 23, 2016
1 parent 1f24987 commit 9867131
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions deepdiff/model.py
Expand Up @@ -398,10 +398,10 @@ def access_partial(self, force=None):
Will strictly return partials of Python-parsable expressions. The result those yield will compare
equal to the objects in question.
If 'yes':
Will return a partial including '(unrepresentable)' instread of the non string-representable part.
Will return a partial including '(unrepresentable)' instead of the non string-representable part.
"""
stringified = self._param_to_str()
stringified = self._param_to_str(force)
if stringified:
return self._format_partial(stringified)

Expand All @@ -414,7 +414,7 @@ def access_string(self, parentname):
return None

@abstractmethod
def _format_partial(self, partial):
def _format_partial(self, partial): # pragma: no cover
"""
Formats an access partial to create a valid partial python string representing this relationship.
E.g. for a dict, this turns a partial param "42" into "[42]".
Expand Down
7 changes: 7 additions & 0 deletions tests/test_diff_text.py
Expand Up @@ -407,6 +407,13 @@ def test_set(self):
'set_item_added': {'root[3]', 'root[5]'}, 'set_item_removed': {'root[8]'}}
self.assertEqual(ddiff, result)

def test_set_strings(self):
t1 = {"veggies", "tofu"}
t2 = {"veggies", "tofu", "seitan"}
ddiff = DeepDiff(t1, t2)
result = {'set_item_added': {"root['seitan']"}}
self.assertEqual(ddiff, result)

def test_frozenset(self):
t1 = frozenset([1, 2, 'B'])
t2 = frozenset([1, 2, 3, 5])
Expand Down
6 changes: 6 additions & 0 deletions tests/test_model.py
Expand Up @@ -103,3 +103,9 @@ def test_automatic_child_rel(self):
def test_path(self):
# Provides textual path all the way through
self.assertEqual(self.lowest.path("self.t1"), "self.t1[1337].a")


class ChildRelationshipTestCase(TestCase):
def test_create_invalid_klass(self):
with self.assertRaises(TypeError):
ChildRelationship.create(DiffLevel, "hello", 42)

0 comments on commit 9867131

Please sign in to comment.