From 14318dc7960d769c370910d9b092c9256e1dec96 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Mon, 28 Jul 2014 11:28:20 +0200 Subject: [PATCH 1/8] Add missing newline at the end of file --- fluent/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fluent/handler.py b/fluent/handler.py index edcf840..94dfcdf 100644 --- a/fluent/handler.py +++ b/fluent/handler.py @@ -75,4 +75,4 @@ def close(self): self.sender._close() logging.Handler.close(self) finally: - self.release() \ No newline at end of file + self.release() From a782befab72b4f4179ece7df3657258093f70a27 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Mon, 28 Jul 2014 11:35:43 +0200 Subject: [PATCH 2/8] Remove useless way of running unittests There is already the perfectly fine `python ./setup.py test` or `python ./setup.py nosetest` if nose is installed and tox. The run_tests script is based on tests module importing all submodules but this currently fails as it seems some files were not added to the VCS in commit "implement UDS (Unix Domain Socket) sender" commit. --- run_tests.py | 6 ------ tests/__init__.py | 6 ------ 2 files changed, 12 deletions(-) delete mode 100644 run_tests.py diff --git a/run_tests.py b/run_tests.py deleted file mode 100644 index 93482eb..0000000 --- a/run_tests.py +++ /dev/null @@ -1,6 +0,0 @@ -import unittest - -from tests import * - -if __name__ == '__main__': - unittest.main() diff --git a/tests/__init__.py b/tests/__init__.py index 7bcee4d..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- - -from tests.test_event import * -from tests.test_handler import * -from tests.test_sender import * -from tests.test_unix_domain_socket_sender import * From 6c78609efded3489c7b7b28b21fd89d36ee1f379 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Mon, 28 Jul 2014 11:38:08 +0200 Subject: [PATCH 3/8] Update/Clean up tox.ini configuration Recent tox.ini as predefined definitions for most python interpreters so just remove them. Also, py32 and py33 are not available on current OSX release so enabling the skip_missing_interpreter looks like a good idea for development purpose. --- tox.ini | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tox.ini b/tox.ini index 262a74c..b7c5b17 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,7 @@ [tox] -envlist = py26, py27, py32 +minversion = 1.7.2 +envlist = py26, py27, py32, py33, py34 +skip_missing_interpreters = True [testenv] commands=python setup.py test - -[testenv:py26] -basepython = python2.6 - -[testenv:py27] -basepython = python2.7 - -[testenv:py32] -basepython = python3.2 From 4f6f72155be482ef7fe805c995751a1eeb2abb71 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Mon, 28 Jul 2014 11:47:15 +0200 Subject: [PATCH 4/8] Add python3 support in handler.py Not really a regression since previous code has this problem with unicode but comes from "Simplify check for string in record formating" commit. --- fluent/handler.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fluent/handler.py b/fluent/handler.py index 94dfcdf..121dadd 100644 --- a/fluent/handler.py +++ b/fluent/handler.py @@ -8,6 +8,11 @@ except ImportError: import json +try: + basestring +except NameError: + basestring = (str, bytes) + from fluent import sender From 34d7793857c2d37247845c2cb5f5a338bd5e7366 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Mon, 28 Jul 2014 11:48:54 +0200 Subject: [PATCH 5/8] Fix DeprecationWarning in unittests (dropped in python 3) --- tests/test_handler.py | 4 ++-- tests/test_sender.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_handler.py b/tests/test_handler.py index e964294..7f944a8 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -42,5 +42,5 @@ def test_simple(self): eq('app.follow', data[0][0]) eq('userA', data[0][2]['from']) eq('userB', data[0][2]['to']) - self.assert_(data[0][1]) - self.assert_(isinstance(data[0][1], int)) + self.assertTrue(data[0][1]) + self.assertTrue(isinstance(data[0][1], int)) diff --git a/tests/test_sender.py b/tests/test_sender.py index ae47592..e2e4335 100644 --- a/tests/test_sender.py +++ b/tests/test_sender.py @@ -32,5 +32,5 @@ def test_simple(self): eq(3, len(data[0])) eq('test.foo', data[0][0]) eq({'bar': 'baz'}, data[0][2]) - self.assert_(data[0][1]) - self.assert_(isinstance(data[0][1], int)) + self.assertTrue(data[0][1]) + self.assertTrue(isinstance(data[0][1], int)) From b45b4a367ca13bdf97e36f62193182c81ca4afd3 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Mon, 28 Jul 2014 11:55:38 +0200 Subject: [PATCH 6/8] Switch tests runner to nose Enable coverage and add relevant files to print a nice report. --- .coveragerc | 8 ++++++++ setup.cfg | 8 ++++++++ tests/test_event.py | 2 +- tox.ini | 4 +++- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .coveragerc create mode 100644 setup.cfg diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..3d5fc07 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,8 @@ +# http://nedbatchelder.com/code/coverage/config.html#config + +[run] +branch = True +omit = */tests/* + +[report] +omit = */tests/* diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..633f7f5 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,8 @@ +[nosetests] +match = ^test_ +cover-package = fluent +with-coverage = 1 +cover-erase = 1 +cover-branches = 1 +cover-inclusive = 1 +cover-min-percentage = 70 diff --git a/tests/test_event.py b/tests/test_event.py index ef11dd0..8a0669b 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -9,7 +9,7 @@ class TestEvent(unittest.TestCase): - def testLogging(self): + def test_logging(self): # send event with tag app.follow event.Event('follow', { 'from': 'userA', diff --git a/tox.ini b/tox.ini index b7c5b17..21cc4a2 100644 --- a/tox.ini +++ b/tox.ini @@ -4,4 +4,6 @@ envlist = py26, py27, py32, py33, py34 skip_missing_interpreters = True [testenv] -commands=python setup.py test +deps = nose + coverage +commands = python setup.py nosetests From 4b690c3a7ab9630e3316cc5b141bd77c83898851 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Mon, 28 Jul 2014 11:56:27 +0200 Subject: [PATCH 7/8] Add travis-ci and coveralls integration --- .travis.yml | 15 +++++++++++++++ README.md | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..505b9ff --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.4" +# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors +install: + - "pip install --use-mirrors -e ." + - "pip install coverage coveralls" +script: + - "python ./setup.py nosetests" +after_success: + - coveralls diff --git a/README.md b/README.md index a455bc3..f1352af 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # A Python structured logger for Fluentd +[![Build Status](https://travis-ci.org/EvaSDK/fluent-logger-python.svg?branch=master)](https://travis-ci.org/EvaSDK/fluent-logger-python) +[![Coverage Status](https://coveralls.io/repos/EvaSDK/fluent-logger-python/badge.png)](https://coveralls.io/r/EvaSDK/fluent-logger-python) Many web/mobile applications generate huge amount of event logs (c,f. login, logout, purchase, follow, etc). To analyze these event logs could be really valuable for improving the service. However, the challenge is collecting these logs easily and reliably. From fdd3ab550c85446b8c09948864abb93c6413f561 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Fri, 1 Aug 2014 13:13:57 +0200 Subject: [PATCH 8/8] Instruct coverage to ignore module try/except handling --- fluent/handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fluent/handler.py b/fluent/handler.py index 121dadd..9bf214d 100644 --- a/fluent/handler.py +++ b/fluent/handler.py @@ -5,12 +5,12 @@ try: import simplejson as json -except ImportError: +except ImportError: # pragma: no cover import json try: basestring -except NameError: +except NameError: # pragma: no cover basestring = (str, bytes) from fluent import sender