Permalink
Browse files

Merge pull request #63 from dvarrazzo/update-tests

Several updates to tox testing configuration
  • Loading branch information...
Roman Valls
Roman Valls committed Dec 11, 2012
2 parents 89d2dcf + 4d6820b commit 9b6af7150217611c2b7d72c54baa74d3346b8382
Showing with 47 additions and 34 deletions.
  1. +2 −0 logbook/testsuite/__init__.py
  2. +16 −13 logbook/testsuite/test_contextmanager.py
  3. +19 −16 logbook/testsuite/test_regular.py
  4. +10 −5 tox.ini
@@ -36,6 +36,8 @@ class LogbookTestCase(unittest.TestCase):
def setUp(self):
self.log = logbook.Logger('testlogger')
+# silence deprecation warning displayed on Py 3.2
+LogbookTestCase.assert_ = LogbookTestCase.assertTrue
def make_fake_mail_handler(**kwargs):
class FakeMailHandler(logbook.MailHandler):
@@ -325,19 +325,22 @@ def test_syslog_handler(self):
to_test.append((socket.AF_UNIX, self.filename))
for sock_family, address in to_test:
inc = socket.socket(sock_family, socket.SOCK_DGRAM)
- inc.bind(address)
- inc.settimeout(1)
- for app_name in [None, 'Testing']:
- handler = logbook.SyslogHandler(app_name, inc.getsockname())
- with handler:
- self.log.warn('Syslog is weird')
- try:
- rv = inc.recvfrom(1024)[0]
- except socket.error:
- self.fail('got timeout on socket')
- self.assertEqual(rv, (
- u'<12>%stestlogger: Syslog is weird\x00' %
- (app_name and app_name + u':' or u'')).encode('utf-8'))
+ try:
+ inc.bind(address)
+ inc.settimeout(1)
+ for app_name in [None, 'Testing']:
+ handler = logbook.SyslogHandler(app_name, inc.getsockname())
+ with handler:
+ self.log.warn('Syslog is weird')
+ try:
+ rv = inc.recvfrom(1024)[0]
+ except socket.error:
+ self.fail('got timeout on socket')
+ self.assertEqual(rv, (
+ u'<12>%stestlogger: Syslog is weird\x00' %
+ (app_name and app_name + u':' or u'')).encode('utf-8'))
+ finally:
+ inc.close()
def test_handler_processors(self):
handler = make_fake_mail_handler(format_string='''\
@@ -496,22 +496,25 @@ def test_syslog_handler(self):
to_test.append((socket.AF_UNIX, self.filename))
for sock_family, address in to_test:
inc = socket.socket(sock_family, socket.SOCK_DGRAM)
- inc.bind(address)
- inc.settimeout(1)
- for app_name in [None, 'Testing']:
- handler = logbook.SyslogHandler(app_name, inc.getsockname())
- handler.push_thread()
- try:
- self.log.warn('Syslog is weird')
- finally:
- handler.pop_thread()
- try:
- rv = inc.recvfrom(1024)[0]
- except socket.error:
- self.fail('got timeout on socket')
- self.assertEqual(rv, (
- u'<12>%stestlogger: Syslog is weird\x00' %
- (app_name and app_name + u':' or u'')).encode('utf-8'))
+ try:
+ inc.bind(address)
+ inc.settimeout(1)
+ for app_name in [None, 'Testing']:
+ handler = logbook.SyslogHandler(app_name, inc.getsockname())
+ handler.push_thread()
+ try:
+ self.log.warn('Syslog is weird')
+ finally:
+ handler.pop_thread()
+ try:
+ rv = inc.recvfrom(1024)[0]
+ except socket.error:
+ self.fail('got timeout on socket')
+ self.assertEqual(rv, (
+ u'<12>%stestlogger: Syslog is weird\x00' %
+ (app_name and app_name + u':' or u'')).encode('utf-8'))
+ finally:
+ inc.close()
def test_handler_processors(self):
handler = make_fake_mail_handler(format_string='''\
View
15 tox.ini
@@ -1,22 +1,21 @@
[tox]
-envlist=py24,py25,py26,py27,py31,docs
+envlist=py24,py25,py26,py27,py31,py32,docs
[testenv]
deps=
SQLAlchemy
pyzmq
execnet
Jinja2
-commands=python -c __import__('unittest').main('logbook.testsuite','suite')
+commands=python -c __import__(\'unittest\').main(\'logbook.testsuite\',\'suite\')
changedir={toxworkdir}
[testenv:py24]
deps=
SQLAlchemy
pysqlite
- simplejson
+ simplejson==2.0.9
multiprocessing
- pyzmq
execnet
Jinja2
@@ -25,7 +24,7 @@ deps=
SQLAlchemy
simplejson
multiprocessing
- pyzmq
+ pyzmq==2.1.11
execnet
Jinja2
@@ -35,6 +34,12 @@ deps=
execnet
Jinja2
+[testenv:py32]
+deps=
+ SQLAlchemy
+ execnet
+ Jinja2
+
[testenv:docs]
deps=
Sphinx

0 comments on commit 9b6af71

Please sign in to comment.