aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_pyg.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2019-10-01 14:44:02 +0200
committerMatěj Cepl <mcepl@cepl.eu>2019-10-01 14:44:02 +0200
commitd6b4d3860c4b36d35b9a8a96dcdf49093a139650 (patch)
tree980bea91eda072344f47c29f7311ac9922c14497 /test/test_pyg.py
parentc60e11ceba4fc9ac017e8b1c6a2f1eab810f2dc7 (diff)
downloadpyg-d6b4d3860c4b36d35b9a8a96dcdf49093a139650.tar.gz
A ways better.
Tentatively fixes #7
Diffstat (limited to 'test/test_pyg.py')
-rwxr-xr-xtest/test_pyg.py19
1 files changed, 5 insertions, 14 deletions
diff --git a/test/test_pyg.py b/test/test_pyg.py
index e6b8fca..4076fc3 100755
--- a/test/test_pyg.py
+++ b/test/test_pyg.py
@@ -6,6 +6,7 @@ import subprocess
import unittest
import mail2news
+import news2mail
class TestM2N(unittest.TestCase):
@@ -27,12 +28,7 @@ one line test
""" % (mail2news.VERSION, mail2news.DESC)
def test_m2n(self):
- 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())
+ out = mail2news.main(['-T', '-v', '-i', 'examples/mail', '-n', 'pyg.test'])
self.assertEqual(out, self.expected_output)
@@ -59,22 +55,17 @@ 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, err = pid.communicate(in_message)
+ out = news2mail.main(['-T', '-v', '-t', 'test@example.com',
+ '-s', 'sender@example.com',
+ '-w', 'examples/whitelist.example'])
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)