aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_pyg.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_pyg.py')
-rw-r--r--[-rwxr-xr-x]test/test_pyg.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/test/test_pyg.py b/test/test_pyg.py
index ddf8146..d3fa3a7 100755..100644
--- 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)