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

Side by Side Diff: client/common_lib/utils_unittest.py

Issue 3554003: Merge remote branch 'cros/upstream' into tempbranch3 (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/common_lib/utils.py ('k') | client/deps/boottool/boottool.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 import os, unittest, StringIO, socket, urllib2, shutil, subprocess, logging 3 import os, unittest, StringIO, socket, urllib2, shutil, subprocess, logging
4 4
5 import common 5 import common
6 from autotest_lib.client.common_lib import utils, autotemp 6 from autotest_lib.client.common_lib import utils, autotemp
7 from autotest_lib.client.common_lib.test_utils import mock 7 from autotest_lib.client.common_lib.test_utils import mock
8 8
9 9
10 class test_read_one_line(unittest.TestCase): 10 class test_read_one_line(unittest.TestCase):
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 766
767 try: 767 try:
768 result = utils.args_to_dict(['ab-c:DeF', '--SyS=DEf', 'a*=b', 'a*b', 768 result = utils.args_to_dict(['ab-c:DeF', '--SyS=DEf', 'a*=b', 'a*b',
769 ':VAL', '=VVV', 'WORD']) 769 ':VAL', '=VVV', 'WORD'])
770 self.assertEqual({}, result) 770 self.assertEqual({}, result)
771 finally: 771 finally:
772 # Restore level. 772 # Restore level.
773 logger.setLevel(saved_level) 773 logger.setLevel(saved_level)
774 774
775 775
776 class test_get_random_port(unittest.TestCase):
777 def do_bind(self, port, socket_type, socket_proto):
778 s = socket.socket(socket.AF_INET, socket_type, socket_proto)
779 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
780 s.bind(('', port))
781 return s
782
783
784 def test_get_port(self):
785 for _ in xrange(100):
786 p = utils.get_unused_port()
787 s = self.do_bind(p, socket.SOCK_STREAM, socket.IPPROTO_TCP)
788 self.assert_(s.getsockname())
789 s = self.do_bind(p, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
790 self.assert_(s.getsockname())
791
792
776 if __name__ == "__main__": 793 if __name__ == "__main__":
777 unittest.main() 794 unittest.main()
OLDNEW
« no previous file with comments | « client/common_lib/utils.py ('k') | client/deps/boottool/boottool.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698