Skip to content

Commit

Permalink
There is not need to check for OrderedDict without Python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimegildesagredo committed Oct 25, 2018
1 parent 7fe7fde commit b29ca84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
11 changes: 4 additions & 7 deletions expects/matchers/built_in/start_end_with.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ def _match(self, subject):
return self._matches(subject)

def _is_unordered_dict(self, subject):
if isinstance(subject, collections.Mapping):
if not hasattr(collections, 'OrderedDict'):
return True

return not isinstance(subject, collections.OrderedDict)

return False
return (
isinstance(subject, collections.Mapping) and
not isinstance(subject, collections.OrderedDict)
)

def _match_negated(self, subject):
if self._is_unordered_dict(subject):
Expand Down
8 changes: 1 addition & 7 deletions specs/matchers/built_in/end_with_spec.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*

try:
from collections import OrderedDict
except ImportError:
OrderedDict = lambda *args: None
from collections import OrderedDict

from expects import *
from expects.testing import failure
Expand All @@ -28,9 +25,6 @@
expect(self.lst).to(end_with(*self.lst[-2:]))

with it('should pass if ordered dict ends with keys'):
if self.ordered_dct is None:
return

expected_args = list(self.ordered_dct)[:2]

expect(self.ordered_dct).to(end_with(*expected_args))
Expand Down
8 changes: 1 addition & 7 deletions specs/matchers/built_in/start_with_spec.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*

try:
from collections import OrderedDict
except ImportError:
OrderedDict = lambda *args: None
from collections import OrderedDict

from expects import *
from expects.testing import failure
Expand All @@ -28,9 +25,6 @@
expect(self.lst).to(start_with(*self.lst[:2]))

with it('passes if ordered dict starts with keys'):
if self.ordered_dct is None:
return

expected_args = list(self.ordered_dct)[:2]

expect(self.ordered_dct).to(start_with(*expected_args))
Expand Down

0 comments on commit b29ca84

Please sign in to comment.