Import and use unittest2 without aliasing it

wip-fakessh-exit-status
Alex Willmer 7 years ago committed by David Wilson
parent e8e023ce59
commit 7e01c5bed5

@ -1,7 +1,7 @@
import logging
import time
import unittest2 as unittest
import unittest2
import mitogen.core
import mitogen.master
@ -89,4 +89,4 @@ class CallFunctionTest(testlib.RouterMixin, testlib.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest2
import mitogen.core
import testlib
@ -17,4 +17,4 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -2,14 +2,14 @@
import os
import shutil
import unittest2 as unittest
import unittest2
import mitogen.fakessh
import testlib
class RsyncTest(testlib.DockerMixin, unittest.TestCase):
class RsyncTest(testlib.DockerMixin, unittest2.TestCase):
def test_rsync_from_master(self):
context = self.docker_ssh_any()
@ -60,4 +60,4 @@ class RsyncTest(testlib.DockerMixin, unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -1,7 +1,7 @@
import subprocess
import unittest2 as unittest
import unittest2
import mitogen.master
import testlib
@ -40,4 +40,4 @@ class CommandLineTest(testlib.RouterMixin, testlib.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -1,5 +1,5 @@
import unittest2 as unittest
import unittest2
import testlib
import id_allocation
@ -13,4 +13,4 @@ class SlaveTest(testlib.RouterMixin, testlib.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -6,7 +6,7 @@ import zlib
import mock
import pytest
import unittest2 as unittest
import unittest2
import mitogen.core
import testlib
@ -128,4 +128,4 @@ class EmailParseAddrSysTest(testlib.RouterMixin, testlib.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -1,7 +1,7 @@
import os
import unittest2 as unittest
import unittest2
import mitogen
import mitogen.ssh
@ -11,7 +11,7 @@ import testlib
import plain_old_module
class LocalTest(testlib.RouterMixin, unittest.TestCase):
class LocalTest(testlib.RouterMixin, unittest2.TestCase):
stream_class = mitogen.ssh.Stream
def test_stream_name(self):
@ -21,4 +21,4 @@ class LocalTest(testlib.RouterMixin, unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -2,13 +2,13 @@
import subprocess
import time
import unittest2 as unittest
import unittest2
import testlib
import mitogen.master
class ScanCodeImportsTest(unittest.TestCase):
class ScanCodeImportsTest(unittest2.TestCase):
func = staticmethod(mitogen.master.scan_code_imports)
def test_simple(self):
@ -22,7 +22,7 @@ class ScanCodeImportsTest(unittest.TestCase):
])
class IterReadTest(unittest.TestCase):
class IterReadTest(unittest2.TestCase):
func = staticmethod(mitogen.master.iter_read)
def make_proc(self):
@ -74,7 +74,7 @@ class IterReadTest(unittest.TestCase):
proc.terminate()
class WriteAllTest(unittest.TestCase):
class WriteAllTest(unittest2.TestCase):
func = staticmethod(mitogen.master.write_all)
def make_proc(self):
@ -115,4 +115,4 @@ class WriteAllTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -1,6 +1,6 @@
import inspect
import unittest2 as unittest
import unittest2
import mitogen.master
@ -146,4 +146,4 @@ class FindRelatedImportsTest(testlib.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -1,6 +1,6 @@
import os
import unittest2 as unittest
import unittest2
import testlib
@ -17,4 +17,4 @@ class NestedTest(testlib.RouterMixin, testlib.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -3,7 +3,7 @@ import mock
import subprocess
import sys
import unittest2 as unittest
import unittest2
import mitogen.master
import testlib
@ -12,7 +12,7 @@ import plain_old_module
import simple_pkg.a
class GoodModulesTest(testlib.RouterMixin, unittest.TestCase):
class GoodModulesTest(testlib.RouterMixin, unittest2.TestCase):
def test_plain_old_module(self):
# The simplest case: a top-level module with no interesting imports or
# package machinery damage.
@ -34,7 +34,7 @@ class GoodModulesTest(testlib.RouterMixin, unittest.TestCase):
self.assertEquals(output, "['__main__', 50]\n")
class BrokenModulesTest(unittest.TestCase):
class BrokenModulesTest(unittest2.TestCase):
def test_obviously_missing(self):
# Ensure we don't crash in the case of a module legitimately being
# unavailable. Should never happen in the real world.
@ -79,4 +79,4 @@ class BrokenModulesTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -1,5 +1,5 @@
import unittest2 as unittest
import unittest2
import mitogen.master
@ -262,4 +262,4 @@ class GetTest(testlib.RouterMixin, testlib.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -2,13 +2,13 @@ import mitogen
import mitogen.ssh
import mitogen.utils
import unittest2 as unittest
import unittest2
import testlib
import plain_old_module
class FakeSshTest(testlib.RouterMixin, unittest.TestCase):
class FakeSshTest(testlib.RouterMixin, unittest2.TestCase):
def test_okay(self):
context = self.router.ssh(
hostname='hostname',
@ -20,7 +20,7 @@ class FakeSshTest(testlib.RouterMixin, unittest.TestCase):
self.assertEquals(3, context.call(plain_old_module.add, 1, 2))
class SshTest(testlib.DockerMixin, unittest.TestCase):
class SshTest(testlib.DockerMixin, unittest2.TestCase):
stream_class = mitogen.ssh.Stream
def test_stream_name(self):
@ -101,4 +101,4 @@ class SshTest(testlib.DockerMixin, unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

@ -7,7 +7,7 @@ import sys
import time
import urlparse
import unittest2 as unittest
import unittest2
import mitogen.master
if mitogen.is_master: # TODO: shouldn't be necessary.
@ -114,7 +114,7 @@ def wait_for_port(
% (host, port))
class TestCase(unittest.TestCase):
class TestCase(unittest2.TestCase):
def assertRaises(self, exc, func, *args, **kwargs):
"""Like regular assertRaises, except return the exception that was
raised. Can't use context manager because tests must run on Python2.4"""

@ -1,6 +1,6 @@
#!/usr/bin/env python
import unittest2 as unittest
import unittest2
import mitogen.master
import mitogen.utils
@ -15,7 +15,7 @@ def func(router):
return router
class RunWithRouterTest(unittest.TestCase):
class RunWithRouterTest(unittest2.TestCase):
# test_shutdown_on_exception
# test_shutdown_on_success
@ -25,7 +25,7 @@ class RunWithRouterTest(unittest.TestCase):
self.assertFalse(router.broker._thread.isAlive())
class WithRouterTest(unittest.TestCase):
class WithRouterTest(unittest2.TestCase):
def test_with_broker(self):
router = func()
self.assertIsInstance(router, mitogen.master.Router)
@ -33,4 +33,4 @@ class WithRouterTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest2.main()

Loading…
Cancel
Save