Skip to content

Commit

Permalink
fix python 2 unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
willforde committed Aug 21, 2018
1 parent 97cbf11 commit efae7b7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion script.module.codequick/lib/codequick/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def build_path(callback=None, args=None, query=None, **extra_query):
# Encode the query parameters using json
if query:
pickled = binascii.hexlify(pickle.dumps(query, protocol=pickle.HIGHEST_PROTOCOL))
query = "_pickle_=" + pickled.decode("ascii") if PY3 else pickled
query = "_pickle_={}".format(pickled.decode("ascii") if PY3 else pickled)

# Build kodi url with new path and query parameters
return urlparse.urlunsplit(("plugin", plugin_id, route.path, query, ""))
Expand Down
3 changes: 2 additions & 1 deletion tests/test_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def test_duration_invalid(self):
@unittest.skipIf(PY3, "Size is an long in python2")
def test_size_py2(self):
self.base["size"] = "256816"
self.assertIsInstance(self.base["size"], int)
# noinspection PyUnresolvedReferences
self.assertIsInstance(self.base["size"], long)

@unittest.skipUnless(PY3, "Size is an int in python3")
def test_size_py3(self):
Expand Down
20 changes: 10 additions & 10 deletions tests/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,23 +268,23 @@ def test_build_new_path(self):
@unittest.skipIf(PY3, "The pickled string is specific to python 2")
def test_build_path_new_args_py2(self):
ret = support.build_path(self.callback, query={"testdata": "data"})
self.assertEqual(ret, "plugin://script.module.codequick/root?_pickle_="
"80027d71005508746573746461746171015504646174617102732e")
self.assertEqual("plugin://script.module.codequick/root?_pickle_="
"80027d71005508746573746461746171015504646174617102732e", ret)

@unittest.skipUnless(PY3, "The pickled string is specific to python 2")
def test_build_path_new_args_py3(self):
ret = support.build_path(self.callback, query={"testdata": "data"})
self.assertEqual(ret, "plugin://script.module.codequick/root?_pickle_="
"80049516000000000000007d948c087465737464617461948c046461746194732e")
self.assertEqual("plugin://script.module.codequick/root?_pickle_="
"80049516000000000000007d948c087465737464617461948c046461746194732e", ret)

@unittest.skipIf(PY3, "The pickled string is specific to python 2")
def test_build_path_extra_args_py2(self):
support.dispatcher.params["_title_"] = "video"
try:
ret = support.build_path(self.callback, testdata="data")
self.assertEqual(ret, "plugin://script.module.codequick/root?_pickle_="
"80027d71002855075f7469746c655f71015505766964656f71"
"025508746573746461746171035504646174617104752e")
self.assertEqual("plugin://script.module.codequick/root?_pickle_="
"80027d71002855075f7469746c655f71015505766964656f71"
"025508746573746461746171035504646174617104752e", ret)
finally:
del support.dispatcher.params["_title_"]

Expand All @@ -293,8 +293,8 @@ def test_build_path_extra_args_py3(self):
support.dispatcher.params["_title_"] = "video"
try:
ret = support.build_path(self.callback, testdata="data")
self.assertEqual(ret, "plugin://script.module.codequick/root?_pickle_="
"80049529000000000000007d94288c075f7469746c655f948c"
"05766964656f948c087465737464617461948c046461746194752e")
self.assertEqual("plugin://script.module.codequick/root?_pickle_="
"80049529000000000000007d94288c075f7469746c655f948c"
"05766964656f948c087465737464617461948c046461746194752e", ret)
finally:
del support.dispatcher.params["_title_"]

0 comments on commit efae7b7

Please sign in to comment.