From 45855f6998e75c04208019222e6a5426d8c5a2ba Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Thu, 19 Nov 2015 23:34:32 -0800 Subject: [PATCH] fix tests on python 3.5 --- tests/test_logging.py | 21 +++++++++++++++++---- tests/utils.py | 4 ++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/test_logging.py b/tests/test_logging.py index 4da7114..e4c011f 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -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]) diff --git a/tests/utils.py b/tests/utils.py index 4add119..49effb9 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -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)