Products.statusmessages/master: Merge pull request #5 from plone/tomgross-py3
GitHub <jenkins-z4DKO/[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Repository: Products.statusmessages
Branch: refs/heads/master
Date: 2017-07-21T18:30:21+02:00
Author: Jens W. Klein (jensens) <jk-jUMamYRpa/IasaSY4/nUZ7NldLUNz+W/@public.gmane.org>
Commit: https://github.com/plone/Products.statusmessages/commit/890a2ba0153288d212176c1bb716f49f934044a1
Merge pull request #5 from plone/tomgross-py3
Python 3
Files changed:
A buildout.cfg
A requirements.txt
M .gitignore
M CHANGES.rst
M Products/statusmessages/message.py
M Products/statusmessages/tests/test_adapter.py
M Products/statusmessages/tests/test_encoding.py
M setup.py
diff --git a/.gitignore b/.gitignore
index 350b1c5..35500ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,9 @@
*.egg-info
-*.pyc
-*.pyo
+*.py[co]
+.installed.cfg
+/bin
+/parts
+/develop-eggs
+/include
+/lib*
+pip-selfcheck.json
diff --git a/CHANGES.rst b/CHANGES.rst
index 718083c..18ea721 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -10,7 +10,8 @@ Breaking changes:
New features:
-- *add item here*
+- Python 3 compatibility
+ [tomgross]
Bug fixes:
diff --git a/Products/statusmessages/message.py b/Products/statusmessages/message.py
index ef67073..7df3cb1 100644
--- a/Products/statusmessages/message.py
+++ b/Products/statusmessages/message.py
@@ -1,8 +1,8 @@
-import struct
-
+from __future__ import unicode_literals
+from Products.statusmessages.interfaces import IMessage
from zope.interface import implementer
-from Products.statusmessages.interfaces import IMessage
+import struct
def _utf8(value):
@@ -12,6 +12,7 @@ def _utf8(value):
return value
return ''
+
def _unicode(value):
return unicode(value, 'utf-8', 'ignore')
@@ -28,11 +29,11 @@ class Message:
True
>>> status = Message(u'this is a test', type=u'info')
- >>> status.message
- u'this is a test'
+ >>> status.message == 'this is a test'
+ True
- >>> status.type
- u'info'
+ >>> status.type == 'info'
+ True
It is quite common to use MessageID's as status messages:
@@ -43,17 +44,17 @@ class Message:
>>> msg = msg_factory(u'test_message', default=u'Default text')
>>> status = Message(msg, type=u'warn')
- >>> status.type
- u'warn'
+ >>> status.type == 'warn'
+ True
>>> type(status.message) is I18NMessage
True
- >>> status.message.default
- u'Default text'
+ >>> status.message.default == 'Default text'
+ True
- >>> status.message.domain
- 'test'
+ >>> status.message.domain == u'test'
+ True
"""
diff --git a/Products/statusmessages/tests/test_adapter.py b/Products/statusmessages/tests/test_adapter.py
index 056db5b..c86bd3f 100644
--- a/Products/statusmessages/tests/test_adapter.py
+++ b/Products/statusmessages/tests/test_adapter.py
@@ -3,14 +3,11 @@
StatusMessage adapter tests.
"""
-from plone.app.testing import PLONE_INTEGRATION_TESTING
import unittest
class TestAdapter(unittest.TestCase):
- layer = PLONE_INTEGRATION_TESTING
-
def test_directives(self):
"""
Test status messages
diff --git a/Products/statusmessages/tests/test_encoding.py b/Products/statusmessages/tests/test_encoding.py
index b40e674..9690677 100644
--- a/Products/statusmessages/tests/test_encoding.py
+++ b/Products/statusmessages/tests/test_encoding.py
@@ -3,14 +3,11 @@
Encoding tests.
"""
-from plone.app.testing import PLONE_INTEGRATION_TESTING
import unittest
class TestEncoding(unittest.TestCase):
- layer = PLONE_INTEGRATION_TESTING
-
def test_encoding(self):
r"""
Test message encoding:
diff --git a/buildout.cfg b/buildout.cfg
new file mode 100644
index 0000000..e93924d
--- /dev/null
+++ b/buildout.cfg
@@ -0,0 +1,9 @@
+[buildout]
+parts = test
+extends = https://raw.githubusercontent.com/zopefoundation/Zope/4.0a6/versions.cfg
+develop = .
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = Products.statusmessages [test]
+
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..244887f
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+setuptools==33.1.1
+zc.buildout==2.8.0
diff --git a/setup.py b/setup.py
index fe5462f..3b1e53f 100644
--- a/setup.py
+++ b/setup.py
@@ -20,8 +20,9 @@
'Framework :: Zope2',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
- 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
],
keywords='Zope CMF Plone status messages i18n',
author='Hanno Schlichting',
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot