From 11bf7a9f227e804187904811526c9403006e7c80 Mon Sep 17 00:00:00 2001 From: ierror Date: Thu, 3 Jul 2014 09:43:23 +0200 Subject: [PATCH 1/5] make test/emails/ dir relative to test script --- test/test_email_reply_parser.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/test_email_reply_parser.py b/test/test_email_reply_parser.py index 2255e64..77ec83c 100644 --- a/test/test_email_reply_parser.py +++ b/test/test_email_reply_parser.py @@ -5,9 +5,10 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) from email_reply_parser import EmailReplyParser +TEST_EMAILS_DIR = os.path.join(os.path.dirname(__file__), 'emails') -class EmailMessageTest(unittest.TestCase): +class EmailMessageTest(unittest.TestCase): def test_simple_body(self): message = self.get_email('email_1_1') @@ -102,17 +103,18 @@ def test_reply_is_parsed(self): self.assertTrue("You can list the keys for the bucket" in message.reply) def test_sent_from_iphone(self): - with open('test/emails/email_iPhone.txt') as email: + with open(os.path.join(TEST_EMAILS_DIR, 'email_iPhone.txt')) as email: self.assertTrue("Sent from my iPhone" not in EmailReplyParser.parse_reply(email.read())) def test_email_one_is_not_on(self): - with open('test/emails/email_one_is_not_on.txt') as email: - self.assertTrue("On Oct 1, 2012, at 11:55 PM, Dave Tapley wrote:" not in EmailReplyParser.parse_reply(email.read())) + with open(os.path.join(TEST_EMAILS_DIR, 'email_one_is_not_on.txt')) as email: + self.assertTrue( + "On Oct 1, 2012, at 11:55 PM, Dave Tapley wrote:" not in EmailReplyParser.parse_reply(email.read())) def get_email(self, name): """ Return EmailMessage instance """ - with open('test/emails/%s.txt' % name) as f: + with open(os.path.join(TEST_EMAILS_DIR, '%s.txt' % name)) as f: text = f.read() return EmailReplyParser.read(text) From 17649d82966f960d21f08d8f3e598f4128928b73 Mon Sep 17 00:00:00 2001 From: ierror Date: Thu, 3 Jul 2014 15:39:32 +0200 Subject: [PATCH 2/5] pep8 cleanup --- email_reply_parser/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/email_reply_parser/__init__.py b/email_reply_parser/__init__.py index 5befe48..a103282 100644 --- a/email_reply_parser/__init__.py +++ b/email_reply_parser/__init__.py @@ -96,7 +96,7 @@ def _scan_line(self, line): if re.match(self.SIG_REGEX, line): line.lstrip() - is_quoted = re.match(self.QUOTED_REGEX, line) != None + is_quoted = re.match(self.QUOTED_REGEX, line) is not None if self.fragment and len(line.strip()) == 0: if re.match(self.SIG_REGEX, self.fragment.lines[-1]): @@ -104,7 +104,7 @@ def _scan_line(self, line): self._finish_fragment() if self.fragment and ((self.fragment.quoted == is_quoted) - or (self.fragment.quoted and (self.quote_header(line) or len(line.strip()) == 0))): + or (self.fragment.quoted and (self.quote_header(line) or len(line.strip()) == 0))): self.fragment.lines.append(line) else: @@ -118,7 +118,7 @@ def quote_header(self, line): Returns True or False """ - return re.match(self.QUOTE_HDR_REGEX, line[::-1]) != None + return re.match(self.QUOTE_HDR_REGEX, line[::-1]) is not None def _finish_fragment(self): """ Creates fragment @@ -128,8 +128,8 @@ def _finish_fragment(self): self.fragment.finish() if not self.found_visible: if self.fragment.quoted \ - or self.fragment.signature \ - or (len(self.fragment.content.strip()) == 0): + or self.fragment.signature \ + or (len(self.fragment.content.strip()) == 0): self.fragment.hidden = True else: From 281765549e6ee87f3f5136f63bfe381c9927874c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bo=CC=88rni?= Date: Thu, 3 Jul 2014 18:56:42 +0200 Subject: [PATCH 3/5] use tox for local testing --- .travis.yml | 18 +++++++++++------- tox.ini | 5 +++++ 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml index 7e10db6..a85f837 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,13 @@ language: python + python: - - "2.6" - - "2.7" - - "3.2" - - "3.3" - - "3.4" - - "pypy" -script: python setup.py test + +env: + - TOXENV=py26 + - TOXENV=py27 + - TOXENV=py32 + - TOXENV=py33 + - TOXENV=py34 + - TOXENV=pypy + +script: tox diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..9e35d5d --- /dev/null +++ b/tox.ini @@ -0,0 +1,5 @@ +[tox] +envlist = py26,py27,py32,py33,py34,pypy + +[testenv] +commands = python setup.py test From 5bade7f0cf152e987ccaed1257f8dfb47e778f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bo=CC=88rni?= Date: Thu, 3 Jul 2014 19:01:29 +0200 Subject: [PATCH 4/5] fixed travis settings --- .travis.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index a85f837..7e10db6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,9 @@ language: python - python: - -env: - - TOXENV=py26 - - TOXENV=py27 - - TOXENV=py32 - - TOXENV=py33 - - TOXENV=py34 - - TOXENV=pypy - -script: tox + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "pypy" +script: python setup.py test From 7df7863da7db73f4551b1d443d8897c2af1a6013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bo=CC=88rni?= Date: Sat, 5 Jul 2014 12:21:29 +0200 Subject: [PATCH 5/5] added dir .tox/ to .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 71f7c64..45d9920 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ tests/.DS_Store .project dist/ dist/* - +.tox/