Skip to content

Commit b011d1f

Browse files
authored
Merge pull request #51 from EasyPost/dlc37_unite_python2_and_3
Dicts iterate differently on python 2 vs. 3. Let's sort.
2 parents 35e53e6 + 73efc88 commit b011d1f

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ try:
8080
weight = 21.2
8181
)
8282
except easypost.Error as e:
83-
print(e.message)
83+
print(str(e))
8484
if e.param is not None:
8585
print('Specifically an invalid param: %r' % e.param)
8686

@@ -136,7 +136,7 @@ print(shipment.insurance)
136136
Documentation
137137
-------------
138138

139-
Up-to-date documentation at: <https://www.easypost.com/docs>
139+
Up-to-date documentation is available at: <https://www.easypost.com/docs>
140140

141141

142142
Client Library Development

easypost/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def _utf8(cls, value):
166166
@classmethod
167167
def encode_dict(cls, out, key, dict_value):
168168
n = {}
169-
for k, v in six.iteritems(dict_value):
169+
for k, v in sorted(six.iteritems(dict_value)):
170170
k = cls._utf8(k)
171171
v = cls._utf8(v)
172172
n["%s[%s]" % (key, k)] = v
@@ -203,7 +203,7 @@ def _encode_inner(cls, params):
203203
ENCODERS[type(None)] = cls.encode_none
204204

205205
out = []
206-
for key, value in six.iteritems(params):
206+
for key, value in sorted(six.iteritems(params)):
207207
key = cls._utf8(key)
208208
try:
209209
encoder = ENCODERS[value.__class__]
@@ -449,7 +449,7 @@ def construct_from(cls, values, api_key=None, parent=None, name=None):
449449
def refresh_from(self, values, api_key):
450450
self.api_key = api_key
451451

452-
for k, v in six.iteritems(values):
452+
for k, v in sorted(six.iteritems(values)):
453453
if k == 'id' and self.id != v:
454454
self.id = v
455455

tests/test_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_shipment_report():
1111
)
1212

1313
assert report.object == "ShipmentReport"
14-
assert report.status == "available"
14+
assert report.status in ("available", "new")
1515
assert report.__class__ == easypost.Report
1616

1717
report2 = easypost.Report.retrieve(report.id)
@@ -32,7 +32,7 @@ def test_payment_log_report():
3232
)
3333

3434
assert report.object == "PaymentLogReport"
35-
assert report.status == "available"
35+
assert report.status in ("available", "new")
3636
assert report.__class__ == easypost.Report
3737

3838
report2 = easypost.Report.retrieve(report.id)

tests/test_webhook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_webhooks(per_run_unique):
2828

2929
# Index webhooks
3030
webhooks = easypost.Webhook.all(url=expected_url)
31-
assert webhooks["webhooks"][len(webhooks["webhooks"]) - 1].id == webhook.id
31+
assert any(wh.id == webhook.id for wh in webhooks['webhooks'])
3232

3333
# Delete a webhook
3434
webhook.delete()

0 commit comments

Comments
 (0)