Skip to content

Commit

Permalink
Merge pull request #40 from dhellmann/python-37-support
Browse files Browse the repository at this point in the history
Python 3.7 support
  • Loading branch information
dhellmann committed Apr 19, 2019
2 parents 6f50485 + 40a8ea1 commit 7d06ec1
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 21 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
language: python

# https://docs.travis-ci.com/user/languages/python/

# required for Python >= 3.7
dist: xenial

python:
- "3.5"
- "3.6"
- "3.7"
- "nightly"

# Test the nightly build of cpython, but ignore any failures.
Expand All @@ -25,4 +30,4 @@ before_install:
install: pip install .[test] .[docs]

script:
- ./tools/travis.sh
- ./tools/travis.sh
4 changes: 2 additions & 2 deletions imapautofiler/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def invoke(self, conn, src_mailbox, message_id, message):


class Sort(Action):
"""Move the message based on parsing a destination from a header.
r"""Move the message based on parsing a destination from a header.
The action is indicated with the name ``sort``.
Expand Down Expand Up @@ -195,7 +195,7 @@ def invoke(self, conn, src_mailbox, message_id, message):


class SortMailingList(Sort):
"""Move the message based on the mailing list id.
r"""Move the message based on the mailing list id.
The action is indicated with the name ``sort-mailing-list``.
Expand Down
2 changes: 1 addition & 1 deletion imapautofiler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def get_config(filename):
filename = os.path.expanduser(filename)
LOG.debug('loading config from %s', filename)
with open(filename, 'r', encoding='utf-8') as f:
return yaml.load(f)
return yaml.safe_load(f)
18 changes: 12 additions & 6 deletions imapautofiler/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
# License for the specific language governing permissions and limitations
# under the License.

import datetime
import email.parser
import logging
from email.header import Header
from email.message import Message
import fixtures
import testtools
from email.utils import format_datetime
import datetime
import logging
import unittest

import fixtures


def construct_message(headers):
Expand All @@ -40,7 +41,7 @@ def construct_message(headers):
'multipart/alternative; '
'boundary="Apple-Mail=_F10D7C06-52F7-4F60-BEC9-4D5F29A9BFE1"',
'Message-Id': '<4FF56508-357B-4E73-82DE-458D3EEB2753@example.com>',
'Mime-Version': '1.0 (Mac OS X Mail 9.2 \(3112\))',
'Mime-Version': r'1.0 (Mac OS X Mail 9.2 \(3112\))',
'X-Smtp-Server': 'AE35BF63-D70A-4AB0-9FAA-3F18EB9802A9',
'Subject': 'Re: reply to previous message',
'Date': '{}'.format(past_date),
Expand All @@ -65,7 +66,7 @@ def construct_message(headers):
})


class TestCase(testtools.TestCase):
class TestCase(unittest.TestCase):
_msg = None
_recent_msg = None
_i18n_msg = None
Expand All @@ -78,6 +79,11 @@ def setUp(self):
stdout = self.useFixture(fixtures.StringStream('stdout')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))

def useFixture(self, f):
f.setUp()
self.addCleanup(f.cleanUp)
return f

@property
def msg(self):
if self._msg is None:
Expand Down
9 changes: 7 additions & 2 deletions imapautofiler/tests/test_maildir.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import mailbox
import os.path
import textwrap
import testtools
import unittest

import fixtures

Expand Down Expand Up @@ -54,7 +54,7 @@ def make_message(
return msg


class MaildirTest(testtools.TestCase):
class MaildirTest(unittest.TestCase):

def setUp(self):
super().setUp()
Expand All @@ -68,6 +68,11 @@ def setUp(self):
)
self.client = client.MaildirClient({'maildir': self.tmpdir})

def useFixture(self, f):
f.setUp()
self.addCleanup(f.cleanUp)
return f

def test_list_mailboxes(self):
expected = set(['destination-mailbox', 'source-mailbox'])
actual = set(self.client.list_mailboxes())
Expand Down
2 changes: 1 addition & 1 deletion imapautofiler/tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def test_create_recursive(self):
'recipient': {'substring': 'recipient1@example.com'},
}
r = rules.Recipient(rule_def, {})
self.assertEquals(
self.assertEqual(
{
'recipient': {'substring': 'recipient1@example.com'},
'or': {
Expand Down
10 changes: 5 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ classifier =
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Topic :: Communications :: Email

[files]
Expand All @@ -22,10 +23,9 @@ packages =

[extras]
test =
coverage
pytest
pytest-cov
testtools
coverage>=4.5.3
pytest>=4.4.1
pytest-cov>=2.6.1
fixtures
flake8
docs =
Expand Down
3 changes: 3 additions & 0 deletions tools/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ set -x
# Exit on any error.
set -e

# Show what we have installed
pip freeze

case "$BUILD" in
docs)
python setup.py build_sphinx;;
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
distribute = False
envlist = pep8,py35,py36
envlist = pep8,py36,py37

[testenv]
deps = .[test]
Expand All @@ -9,7 +9,7 @@ commands =
{toxinidir}/tools/travis.sh '{posargs}'

[testenv:pep8]
basepython = python3.5
basepython = python3.7
commands = flake8

[flake8]
Expand Down

0 comments on commit 7d06ec1

Please sign in to comment.