Ticket #23960 make tests run with python 2.4 · bbqstudy/python-api@5da22a7 · GitHub
Skip to content

Commit 5da22a7

Browse files
author
kbehrman
committed
Ticket #23960 make tests run with python 2.4
1 parent 2d4c7cd commit 5da22a7

4 files changed

Lines changed: 22 additions & 9 deletions

File tree

shotgun_api3/shotgun.py

Lines changed: 2 additions & 1 deletion

tests/base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
import unittest
44
from ConfigParser import ConfigParser
55

6-
try:
7-
import simplejson as json
8-
except ImportError:
9-
import json
106

117
import mock
128

139
import shotgun_api3 as api
10+
from shotgun_api3.shotgun import json
1411
from shotgun_api3.shotgun import ServerCapabilities
1512

1613
CONFIG_PATH = 'tests/config'

tests/test_api.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ def test_share_thumbnail(self):
373373

374374
shot_url = urlparse.urlparse(response_shot_thumbnail.get('image'))
375375
version_url = urlparse.urlparse(response_version_thumbnail.get('image'))
376-
self.assertEqual(shot_url.path, version_url.path)
376+
shot_path = _get_path(shot_url)
377+
version_path = _get_path(version_url)
378+
self.assertEqual(shot_path, version_path)
377379

378380
# share thumbnail from source entity with entities
379381
source_thumbnail_id = self.sg.upload_thumbnail("Version",
@@ -401,8 +403,12 @@ def test_share_thumbnail(self):
401403
version_url = urlparse.urlparse(response_version_thumbnail.get('image'))
402404
asset_url = urlparse.urlparse(response_asset_thumbnail.get('image'))
403405

404-
self.assertEqual(version_url.path, shot_url.path)
405-
self.assertEqual(version_url.path, asset_url.path)
406+
shot_path = _get_path(shot_url)
407+
version_path = _get_path(version_url)
408+
asset_path = _get_path(asset_url)
409+
410+
self.assertEqual(version_path, shot_path)
411+
self.assertEqual(version_path, asset_path)
406412

407413
# raise errors when missing required params or providing conflicting ones
408414
self.assertRaises(shotgun_api3.ShotgunError, self.sg.share_thumbnail,
@@ -1422,6 +1428,14 @@ def _has_unicode(data):
14221428
return True
14231429
return False
14241430

1431+
def _get_path(url):
1432+
# url_parse returns native objects for older python versions (2.4)
1433+
if isinstance(url, dict):
1434+
return url.get('path')
1435+
elif isinstance(url, tuple):
1436+
return os.path.join(url[:4])
1437+
else:
1438+
return url.path
14251439

14261440
if __name__ == '__main__':
14271441
unittest.main()

tests/test_api_long.py

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)