From a9c5cf3072b42131eb2da7ac289e256a04a03710 Mon Sep 17 00:00:00 2001 From: carpaIdea Date: Tue, 12 Apr 2016 23:07:27 +0200 Subject: [PATCH 1/5]
semantic element IE fix Some versions of Internet Explorer consider the
semantic element as "unknown". So its initial value is "inline".If we want the behavior of the
element to be the same as in other browsers, we must set it explicitly as a "block." --- applications/examples/static/css/stupid.css | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/examples/static/css/stupid.css b/applications/examples/static/css/stupid.css index 1bce96e4..2a9a321b 100644 --- a/applications/examples/static/css/stupid.css +++ b/applications/examples/static/css/stupid.css @@ -28,6 +28,7 @@ tbody tr {border-bottom:2px solid #f1f1f1} td, th {padding: 5px; text-align: left; vertical-align:top} thead th {vertical-align:bottom} header, footer {with:100%} +main {display: block;} /* IE fix */ @media all and (max-width:599px) { h1{font-size:2em} From 2e63b7637a23fc3e05970834209f19aab45e3739 Mon Sep 17 00:00:00 2001 From: carpaIdea Date: Wed, 13 Apr 2016 00:53:42 +0200 Subject: [PATCH 2/5] box-sizing best practice This code was updated to match new box-sizing best practices. Also prefixes are pretty much dead. (quote from http://www.paulirish.com/2012/box-sizing-border-box-ftw/). More info on https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ --- applications/examples/static/css/stupid.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/examples/static/css/stupid.css b/applications/examples/static/css/stupid.css index 1bce96e4..2a33c971 100644 --- a/applications/examples/static/css/stupid.css +++ b/applications/examples/static/css/stupid.css @@ -5,7 +5,8 @@ ************/ /*** basic styles ***/ -*, *:after, *:before {border:0; margin:0; padding:0; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box} +html {box-sizing:border-box;} +*, *:after, *:before {border:0; margin:0; padding:0; box-sizing:inherit;} html, body {max-width: 100vw; overflow-x: hidden} body {font-family:"HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif} p, li {margin-bottom:0.5em} From 2bf0ad92686c27e5c2ca8f30a3d1ef746c13678e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonel=20C=C3=A2mara?= Date: Wed, 13 Apr 2016 14:00:33 +0100 Subject: [PATCH 3/5] test emails with alternative text and html --- gluon/tests/test_tools.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/gluon/tests/test_tools.py b/gluon/tests/test_tools.py index f7173ca0..62433d7f 100644 --- a/gluon/tests/test_tools.py +++ b/gluon/tests/test_tools.py @@ -36,10 +36,19 @@ class TestMail(unittest.TestCase): """ class Message(object): + def __init__(self, sender, to, payload): self.sender = sender self.to = to self.payload = payload + self._parsed_payload = None + + @property + def parsed_payload(self): + if self._parsed_payload is None: + import email + self._parsed_payload = email.message_from_string(self.payload) + return self._parsed_payload class DummySMTP(object): """ @@ -125,6 +134,19 @@ class TestMail(unittest.TestCase): del TestMail.DummySMTP.users['username'] TestMail.DummySMTP.inbox.pop() + def test_alternative(self): + mail = Mail() + mail.settings.server = 'smtp.example.com:25' + mail.settings.sender = 'you@example.com' + self.assertTrue(mail.send(to=['somebody@example.com'], + message=('Text only', '
HTML Only
'))) + message = TestMail.DummySMTP.inbox.pop() + self.assertTrue(message.parsed_payload.is_multipart()) + self.assertTrue(message.parsed_payload.get_content_type() == 'multipart/alternative') + parts = message.parsed_payload.get_payload() + self.assertTrue('Text only' in parts[0].as_string()) + self.assertTrue('
HTML Only
' in parts[1].as_string()) + def test_html(self): mail = Mail() mail.settings.server = 'smtp.example.com:25' @@ -171,9 +193,7 @@ class TestMail(unittest.TestCase): message='world', attachments=Mail.Attachment(module_file))) message = TestMail.DummySMTP.inbox.pop() - import email - parsed_msg = email.message_from_string(message.payload) - attachment = parsed_msg.get_payload(1).get_payload(decode=True) + attachment = message.parsed_payload.get_payload(1).get_payload(decode=True) with open(module_file, 'rb') as mf: self.assertEqual(attachment.decode('utf-8'), mf.read().decode('utf-8')) # Test missing attachment name error From 02a0d1c9b00cafc67d708d10aaf44e2cf05fc80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonel=20C=C3=A2mara?= Date: Wed, 13 Apr 2016 14:01:36 +0100 Subject: [PATCH 4/5] minor reorder --- gluon/tests/test_tools.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gluon/tests/test_tools.py b/gluon/tests/test_tools.py index 62433d7f..53800e7b 100644 --- a/gluon/tests/test_tools.py +++ b/gluon/tests/test_tools.py @@ -134,6 +134,18 @@ class TestMail(unittest.TestCase): del TestMail.DummySMTP.users['username'] TestMail.DummySMTP.inbox.pop() + def test_html(self): + mail = Mail() + mail.settings.server = 'smtp.example.com:25' + mail.settings.sender = 'you@example.com' + self.assertTrue(mail.send(to=['somebody@example.com'], + subject='hello', + # If reply_to is omitted, then mail.settings.sender is used + reply_to='us@example.com', + message='')) + message = TestMail.DummySMTP.inbox.pop() + self.assertTrue('Content-Type: text/html' in message.payload) + def test_alternative(self): mail = Mail() mail.settings.server = 'smtp.example.com:25' @@ -147,18 +159,6 @@ class TestMail(unittest.TestCase): self.assertTrue('Text only' in parts[0].as_string()) self.assertTrue('
HTML Only
' in parts[1].as_string()) - def test_html(self): - mail = Mail() - mail.settings.server = 'smtp.example.com:25' - mail.settings.sender = 'you@example.com' - self.assertTrue(mail.send(to=['somebody@example.com'], - subject='hello', - # If reply_to is omitted, then mail.settings.sender is used - reply_to='us@example.com', - message='')) - message = TestMail.DummySMTP.inbox.pop() - self.assertTrue('Content-Type: text/html' in message.payload) - def test_ssl(self): mail = Mail() mail.settings.server = 'smtp.example.com:25' From 4bbfe7092768773a5fc2bd938084880783a8db5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonel=20C=C3=A2mara?= Date: Wed, 13 Apr 2016 14:17:30 +0100 Subject: [PATCH 5/5] install a more modern pypy version --- .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.travis.yml b/.travis.yml index bcc9ba01..a785e983 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,22 @@ python: - 'pypy' install: + - | + if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then + export PYENV_ROOT="$HOME/.pyenv" + if [ -f "$PYENV_ROOT/bin/pyenv" ]; then + pushd "$PYENV_ROOT" && git pull && popd + else + rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT" + fi + export PYPY_VERSION="5.0.1" + "$PYENV_ROOT/bin/pyenv" install --skip-existing "pypy-$PYPY_VERSION" + virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION" + source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate" + fi - pip install -e . + before_script: - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install --download-cache $HOME/.pip-cache unittest2; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install --download-cache $HOME/.pip-cache coverage; fi;