From d5fc1faf927a5ff91f3416eb97014c0eadb14742 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Wed, 1 Jul 2020 16:16:44 +0200 Subject: Sync with 0.10.1 release on PyPI Port to Python 3. --- test/test_pyg.py | 22 +++++++++++++++++----- test/test_wlp.py | 2 ++ 2 files changed, 19 insertions(+), 5 deletions(-) mode change 100755 => 100644 test/test_pyg.py mode change 100755 => 100644 test/test_wlp.py (limited to 'test') diff --git a/test/test_pyg.py b/test/test_pyg.py old mode 100755 new mode 100644 index ddf8146..d3fa3a7 --- a/test/test_pyg.py +++ b/test/test_pyg.py @@ -1,10 +1,12 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- + +from __future__ import absolute_import import re import subprocess import unittest import mail2news -import news2mail class TestM2N(unittest.TestCase): @@ -26,7 +28,12 @@ one line test """ % (mail2news.VERSION, mail2news.DESC) def test_m2n(self): - out = mail2news.main(['-T', '-v', '-i', 'examples/mail', '-n', 'pyg.test']) + with open('examples/mail') as in_mail: + pid = subprocess.Popen(['python', 'pygm2n', '-Tv', '-n', 'pyg.test'], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + universal_newlines=True) + out, _ = pid.communicate(in_mail.read()) self.assertEqual(out, self.expected_output) @@ -53,17 +60,22 @@ Resent-Sender: sender@example.com def test_n2m(self): with open('examples/articletest.accepted') as in_mail: + pid = subprocess.Popen(['python', 'pygn2m', '-Tvt', 'test@example.com', + '-s', 'sender@example.com', + '-w', 'examples/whitelist.example'], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + universal_newlines=True) in_message = in_mail.read().replace('pyg@pyg.server.tld', 'kame@inwind.it') - out = news2mail.main(['-T', '-v', '-t', 'test@example.com', - '-s', 'sender@example.com', - '-w', 'examples/whitelist.example']) + out, err = pid.communicate(in_message) out = re.sub(r'^Message-Id:.*$', '', out) # Not sure how to compare two email mesages (with different # times, etc.) so for now just to make sure the script doesn’t # blow up and gives some output # otherwise it would be # self.assertEqual(out, expected_output) + self.assertEqual(pid.returncode, 0) self.assertGreater(len(out), 0) diff --git a/test/test_wlp.py b/test/test_wlp.py old mode 100755 new mode 100644 index 929fb1c..061673c --- a/test/test_wlp.py +++ b/test/test_wlp.py @@ -1,4 +1,6 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- +from __future__ import absolute_import import unittest import wlp_parser -- cgit