fix tests on python 3.5

This commit is contained in:
Alan Hamlett 2015-11-19 23:34:32 -08:00
parent 14a7e6e6c4
commit 45855f6998
2 changed files with 21 additions and 4 deletions

View file

@ -48,8 +48,15 @@ class LoggingTestCase(utils.TestCase):
self.assertEquals(logging.WARNING, logging.getLogger('WakaTime').level)
logfile = os.path.realpath(os.path.expanduser('~/.wakatime.log'))
self.assertEquals(logfile, logging.getLogger('WakaTime').handlers[0].baseFilename)
output = u("\n").join([u(' ').join(x) for x in logs.actual()])
self.assertEquals(output, u("WakaTime WARNING Regex error (unbalanced parenthesis) for include pattern: \\(invalid regex)\nWakaTime WARNING Regex error (unbalanced parenthesis) for exclude pattern: \\(invalid regex)"))
output = [u(' ').join(x) for x in logs.actual()]
expected = u('WakaTime WARNING Regex error (unbalanced parenthesis) for include pattern: \\(invalid regex)')
if self.isPy35:
expected = u('WakaTime WARNING Regex error (unbalanced parenthesis) for include pattern: \\(invalid regex)')
self.assertEquals(output[0], expected)
expected = u('WakaTime WARNING Regex error (unbalanced parenthesis) for exclude pattern: \\(invalid regex)')
if self.isPy35:
expected = u('WakaTime WARNING Regex error (unbalanced parenthesis) for exclude pattern: \\(invalid regex)')
self.assertEquals(output[1], expected)
@log_capture()
def test_log_file_location_can_be_changed(self, logs):
@ -99,8 +106,14 @@ class LoggingTestCase(utils.TestCase):
logfile = os.path.realpath(os.path.expanduser('~/.wakatime.log'))
self.assertEquals(logfile, logging.getLogger('WakaTime').handlers[0].baseFilename)
output = [u(' ').join(x) for x in logs.actual()]
self.assertEquals(output[0], u('WakaTime WARNING Regex error (unbalanced parenthesis) for include pattern: \\(invalid regex)'))
self.assertEquals(output[1], u('WakaTime WARNING Regex error (unbalanced parenthesis) for exclude pattern: \\(invalid regex)'))
expected = u('WakaTime WARNING Regex error (unbalanced parenthesis) for include pattern: \\(invalid regex)')
if self.isPy35:
expected = u('WakaTime WARNING Regex error (unbalanced parenthesis) for include pattern: \\(invalid regex)')
self.assertEquals(output[0], expected)
expected = u('WakaTime WARNING Regex error (unbalanced parenthesis) for exclude pattern: \\(invalid regex)')
if self.isPy35:
expected = u('WakaTime WARNING Regex error (unbalanced parenthesis) for exclude pattern: \\(invalid regex)')
self.assertEquals(output[1], expected)
self.assertEquals(output[2], u('WakaTime DEBUG Sending heartbeat to api at https://wakatime.com/api/v1/heartbeats'))
self.assertIn('Python', output[3])
self.assertIn('response_code', output[4])

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import logging
import sys
from wakatime.compat import u
@ -47,3 +48,6 @@ class TestCase(unittest.TestCase):
def assertListsEqual(self, first_list, second_list):
self.assertEquals(self.normalize_list(first_list), self.normalize_list(second_list))
def isPy35(self):
return (sys.version_info[0] == 3 and sys.version_info[1] == 5)