Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: recipe_engine/unittests/fetch_test.py

Issue 2844203002: [fetch] add tests for fetch subcommand parsing. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/fetch.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/unittests/fetch_test.py
diff --git a/recipe_engine/unittests/fetch_test.py b/recipe_engine/unittests/fetch_test.py
index 81bbd2339da490fac2861e4bc6f695f08272e97f..94b307cf8be07c22717752cf5004bce3fb92cb4a 100755
--- a/recipe_engine/unittests/fetch_test.py
+++ b/recipe_engine/unittests/fetch_test.py
@@ -8,11 +8,16 @@ import itertools
import json
import unittest
+from cStringIO import StringIO
+
import test_env
+import argparse # this is vendored
+
import mock
import subprocess42
+from recipe_engine import common_args
from recipe_engine import fetch
from recipe_engine import package_pb2
from recipe_engine import requests_ssl
@@ -451,5 +456,21 @@ class TestGitiles(unittest.TestCase):
self.assertEqual(result, self.a_meta)
self.assertMultiDone(requests_get)
+
+class TestArgs(unittest.TestCase):
+ def setUp(self):
+ self.p = argparse.ArgumentParser()
+ self.followup = common_args.add_common_args(self.p)
+ subp = self.p.add_subparsers()
+ fetch.add_subparser(subp)
+
+ @mock.patch('argparse._sys.stderr', new_callable=StringIO)
+ def test_no_fetch(self, stderr):
+ with self.assertRaises(SystemExit):
+ args = self.p.parse_args(['--no-fetch', 'fetch'])
+ args.postprocess_func(self.p, args)
+ self.assertIn('--no-fetch does not make sense', stderr.getvalue())
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « recipe_engine/fetch.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698