@@ -18,6 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
+import sys
from django.core.management import call_command
from django.test import TestCase
@@ -46,9 +47,10 @@ class ParsemailTest(TestCase):
def test_missing_project_stdin(self):
path = os.path.join(TEST_MAIL_DIR, '0001-git-pull-request.mbox')
- with open(path) as file_:
- with self.assertRaises(SystemExit) as exc:
- call_command('parsemail', infile=file_)
+ sys.stdin.close()
+ sys.stdin = open(path)
+ with self.assertRaises(SystemExit) as exc:
+ call_command('parsemail', infile=None)
self.assertEqual(exc.exception.code, 1)
@@ -70,10 +72,11 @@ class ParsemailTest(TestCase):
utils.create_state()
path = os.path.join(TEST_MAIL_DIR, '0001-git-pull-request.mbox')
- with open(path) as file_:
- with self.assertRaises(SystemExit) as exc:
- call_command('parsemail', infile=file_,
- list_id=project.listid)
+ sys.stdin.close()
+ sys.stdin = open(path)
+ with self.assertRaises(SystemExit) as exc:
+ call_command('parsemail', infile=None,
+ list_id=project.listid)
self.assertEqual(exc.exception.code, 0)