Hi Stephen, > + 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_) > + > + self.assertEqual(exc.exception.code, 1) > + I don't think this is actually testing stdin. I think you want something like this:
diff --git a/patchwork/tests/test_management.py b/patchwork/tests/test_management.py index f2b968f5be35..42700dd9bb15 100644 --- a/patchwork/tests/test_management.py +++ b/patchwork/tests/test_management.py @@ -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)
signature.asc
Description: PGP signature
_______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork