fix tests on python 3
This commit is contained in:
parent
9c5b31ce04
commit
4ddf48905a
1 changed files with 10 additions and 0 deletions
|
@ -511,6 +511,8 @@ class MainTestCase(utils.TestCase):
|
||||||
response = Response()
|
response = Response()
|
||||||
response.status_code = 500
|
response.status_code = 500
|
||||||
response._content = 'fake content'
|
response._content = 'fake content'
|
||||||
|
if is_py3:
|
||||||
|
response._content = 'fake content'.encode('utf8')
|
||||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||||
|
|
||||||
with utils.TemporaryDirectory() as tempdir:
|
with utils.TemporaryDirectory() as tempdir:
|
||||||
|
@ -530,6 +532,8 @@ class MainTestCase(utils.TestCase):
|
||||||
|
|
||||||
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
||||||
expected = "WakaTime ERROR {'response_code': 500, 'response_content': u'fake content'}"
|
expected = "WakaTime ERROR {'response_code': 500, 'response_content': u'fake content'}"
|
||||||
|
if is_py3:
|
||||||
|
expected = "WakaTime ERROR {'response_code': 500, 'response_content': 'fake content'}"
|
||||||
self.assertEquals(expected, log_output)
|
self.assertEquals(expected, log_output)
|
||||||
|
|
||||||
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
|
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
|
||||||
|
@ -562,12 +566,16 @@ class MainTestCase(utils.TestCase):
|
||||||
|
|
||||||
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
||||||
expected = 'ImportError: No module named special'
|
expected = 'ImportError: No module named special'
|
||||||
|
if is_py3:
|
||||||
|
expected = "ImportError: No module named 'wakatime.dependencies.special'"
|
||||||
self.assertIn(expected, log_output)
|
self.assertIn(expected, log_output)
|
||||||
expected = 'WakaTime DEBUG Sending heartbeat to api at https://api.wakatime.com/api/v1/heartbeats'
|
expected = 'WakaTime DEBUG Sending heartbeat to api at https://api.wakatime.com/api/v1/heartbeats'
|
||||||
self.assertIn(expected, log_output)
|
self.assertIn(expected, log_output)
|
||||||
expected = 'WakaTime DEBUG Traceback'
|
expected = 'WakaTime DEBUG Traceback'
|
||||||
self.assertIn(expected, log_output)
|
self.assertIn(expected, log_output)
|
||||||
expected = "RequestException': u'requests exception'"
|
expected = "RequestException': u'requests exception'"
|
||||||
|
if is_py3:
|
||||||
|
expected = "RequestException': 'requests exception'"
|
||||||
self.assertIn(expected, log_output)
|
self.assertIn(expected, log_output)
|
||||||
|
|
||||||
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
|
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
|
||||||
|
@ -619,6 +627,8 @@ class MainTestCase(utils.TestCase):
|
||||||
|
|
||||||
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
||||||
expected = "WakaTime ERROR {'RequestException': u'requests exception'}"
|
expected = "WakaTime ERROR {'RequestException': u'requests exception'}"
|
||||||
|
if is_py3:
|
||||||
|
expected = "WakaTime ERROR {'RequestException': 'requests exception'}"
|
||||||
self.assertEquals(expected, log_output)
|
self.assertEquals(expected, log_output)
|
||||||
|
|
||||||
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
|
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
|
||||||
|
|
Loading…
Reference in a new issue