class TestMpPlugin(FunctionalTestCase): def setUp(self): super(TestMpPlugin, self).setUp() self.session = session.Session() self.plugin = MultiProcess(session=self.session) def test_flatten_without_fixtures(self): sys.path.append(support_file('scenario/slow')) import test_slow as mod suite = unittest.TestSuite() suite.addTest(mod.TestSlow('test_ok')) suite.addTest(mod.TestSlow('test_fail')) suite.addTest(mod.TestSlow('test_err')) flat = list(self.plugin._flatten(suite)) self.assertEqual(len(flat), 3) def test_flatten_nested_suites(self): sys.path.append(support_file('scenario/slow')) import test_slow as mod suite = unittest.TestSuite() suite.addTest(mod.TestSlow('test_ok')) suite.addTest(mod.TestSlow('test_fail')) suite.addTest(mod.TestSlow('test_err')) suite2 = unittest.TestSuite() suite2.addTest(suite) flat = list(self.plugin._flatten(suite2)) self.assertEqual(len(flat), 3) def test_flatten_respects_module_fixtures(self): sys.path.append(support_file('scenario/module_fixtures')) import test_mf_testcase as mod suite = unittest.TestSuite() suite.addTest(mod.Test('test_1')) suite.addTest(mod.Test('test_2')) flat = list(self.plugin._flatten(suite)) self.assertEqual(flat, ['test_mf_testcase']) def test_flatten_respects_class_fixtures(self): sys.path.append(support_file('scenario/class_fixtures')) import test_cf_testcase as mod suite = unittest.TestSuite() suite.addTest(mod.Test('test_1')) suite.addTest(mod.Test('test_2')) suite.addTest(mod.Test2('test_1')) suite.addTest(mod.Test2('test_2')) flat = list(self.plugin._flatten(suite)) self.assertEqual(flat, [ 'test_cf_testcase.Test2.test_1', 'test_cf_testcase.Test2.test_2', 'test_cf_testcase.Test', ])
class TestMpPlugin(FunctionalTestCase): def setUp(self): super(TestMpPlugin, self).setUp() self.session = session.Session() self.plugin = MultiProcess(session=self.session) def test_flatten_without_fixtures(self): sys.path.append(support_file('scenario/slow')) import test_slow as mod suite = unittest.TestSuite() suite.addTest(mod.TestSlow('test_ok')) suite.addTest(mod.TestSlow('test_fail')) suite.addTest(mod.TestSlow('test_err')) flat = list(self.plugin._flatten(suite)) self.assertEqual(len(flat), 3) def test_flatten_nested_suites(self): sys.path.append(support_file('scenario/slow')) import test_slow as mod suite = unittest.TestSuite() suite.addTest(mod.TestSlow('test_ok')) suite.addTest(mod.TestSlow('test_fail')) suite.addTest(mod.TestSlow('test_err')) suite2 = unittest.TestSuite() suite2.addTest(suite) flat = list(self.plugin._flatten(suite2)) self.assertEqual(len(flat), 3) def test_flatten_respects_module_fixtures(self): sys.path.append(support_file('scenario/module_fixtures')) import test_mf_testcase as mod suite = unittest.TestSuite() suite.addTest(mod.Test('test_1')) suite.addTest(mod.Test('test_2')) flat = list(self.plugin._flatten(suite)) self.assertEqual(flat, ['test_mf_testcase']) def test_flatten_respects_class_fixtures(self): sys.path.append(support_file('scenario/class_fixtures')) import test_cf_testcase as mod suite = unittest.TestSuite() suite.addTest(mod.Test('test_1')) suite.addTest(mod.Test('test_2')) suite.addTest(mod.Test2('test_1')) suite.addTest(mod.Test2('test_2')) flat = list(self.plugin._flatten(suite)) self.assertEqual(flat, ['test_cf_testcase.Test2.test_1', 'test_cf_testcase.Test2.test_2', 'test_cf_testcase.Test', ])
def setUp(self): super(TestMpPlugin, self).setUp() self.session = session.Session() self.plugin = MultiProcess(session=self.session)
class TestMpPlugin(FunctionalTestCase): def setUp(self): super(TestMpPlugin, self).setUp() self.session = session.Session() self.plugin = MultiProcess(session=self.session) def test_flatten_without_fixtures(self): sys.path.append(support_file('scenario/slow')) import test_slow as mod suite = unittest.TestSuite() suite.addTest(mod.TestSlow('test_ok')) suite.addTest(mod.TestSlow('test_fail')) suite.addTest(mod.TestSlow('test_err')) flat = list(self.plugin._flatten(suite)) self.assertEqual(len(flat), 3) def test_flatten_nested_suites(self): sys.path.append(support_file('scenario/slow')) import test_slow as mod suite = unittest.TestSuite() suite.addTest(mod.TestSlow('test_ok')) suite.addTest(mod.TestSlow('test_fail')) suite.addTest(mod.TestSlow('test_err')) suite2 = unittest.TestSuite() suite2.addTest(suite) flat = list(self.plugin._flatten(suite2)) self.assertEqual(len(flat), 3) def test_flatten_respects_module_fixtures(self): sys.path.append(support_file('scenario/module_fixtures')) import test_mf_testcase as mod suite = unittest.TestSuite() suite.addTest(mod.Test('test_1')) suite.addTest(mod.Test('test_2')) flat = list(self.plugin._flatten(suite)) self.assertEqual(flat, ['test_mf_testcase']) def test_flatten_respects_class_fixtures(self): sys.path.append(support_file('scenario/class_fixtures')) import test_cf_testcase as mod suite = unittest.TestSuite() suite.addTest(mod.Test('test_1')) suite.addTest(mod.Test('test_2')) suite.addTest(mod.Test2('test_1')) suite.addTest(mod.Test2('test_2')) suite.addTest(mod.Test3('test_3')) flat = list(self.plugin._flatten(suite)) self.assertEqual(flat, ['test_cf_testcase.Test2.test_1', 'test_cf_testcase.Test2.test_2', 'test_cf_testcase.Test', 'test_cf_testcase.Test3', ]) def test_conn_prep(self): self.plugin.bind_host = None (parent_conn, child_conn) = self.plugin._prepConns() (parent_pipe, child_pipe) = multiprocessing.Pipe() self.assertIsInstance(parent_conn, type(parent_pipe)) self.assertIsInstance(child_conn, type(child_pipe)) self.plugin.bind_host = "127.0.0.1" self.plugin.bind_port = 0 (parent_conn, child_conn) = self.plugin._prepConns() self.assertIsInstance(parent_conn, connection.Listener) self.assertIsInstance(child_conn, tuple) self.assertEqual(parent_conn.address, child_conn[:2]) def test_conn_accept(self): (parent_conn, child_conn) = multiprocessing.Pipe() self.assertEqual(self.plugin._acceptConns(parent_conn), parent_conn) listener = connection.Listener(('127.0.0.1', 0)) with self.assertRaises(RuntimeError): self.plugin._acceptConns(listener) def fake_client(address): client = connection.Client(address) time.sleep(10) client.close() t = threading.Thread(target=fake_client, args=(listener.address,)) t.start() conn = self.plugin._acceptConns(listener) self.assertTrue(hasattr(conn, "send")) self.assertTrue(hasattr(conn, "recv"))
def setUp(self): super(TestMpPlugin, self).setUp() self.session = session.Session() self.plugin = MultiProcess(session=self.session) self.plugin.testRunTimeout = 2
class TestMpPlugin(FunctionalTestCase): def setUp(self): super(TestMpPlugin, self).setUp() self.session = session.Session() self.plugin = MultiProcess(session=self.session) self.plugin.testRunTimeout = 2 def test_flatten_without_fixtures(self): sys.path.append(support_file('scenario/slow')) import test_slow as mod suite = unittest.TestSuite() suite.addTest(mod.TestSlow('test_ok')) suite.addTest(mod.TestSlow('test_fail')) suite.addTest(mod.TestSlow('test_err')) flat = list(self.plugin._flatten(suite)) self.assertEqual(len(flat), 3) def test_flatten_nested_suites(self): sys.path.append(support_file('scenario/slow')) import test_slow as mod suite = unittest.TestSuite() suite.addTest(mod.TestSlow('test_ok')) suite.addTest(mod.TestSlow('test_fail')) suite.addTest(mod.TestSlow('test_err')) suite2 = unittest.TestSuite() suite2.addTest(suite) flat = list(self.plugin._flatten(suite2)) self.assertEqual(len(flat), 3) def test_flatten_respects_module_fixtures(self): sys.path.append(support_file('scenario/module_fixtures')) import test_mf_testcase as mod suite = unittest.TestSuite() suite.addTest(mod.Test('test_1')) suite.addTest(mod.Test('test_2')) flat = list(self.plugin._flatten(suite)) self.assertEqual(flat, ['test_mf_testcase']) def test_flatten_respects_class_fixtures(self): sys.path.append(support_file('scenario/class_fixtures')) import test_cf_testcase as mod suite = unittest.TestSuite() suite.addTest(mod.Test('test_1')) suite.addTest(mod.Test('test_2')) suite.addTest(mod.Test2('test_1')) suite.addTest(mod.Test2('test_2')) suite.addTest(mod.Test3('test_3')) flat = list(self.plugin._flatten(suite)) self.assertEqual(flat, [ 'test_cf_testcase.Test2.test_1', 'test_cf_testcase.Test2.test_2', 'test_cf_testcase.Test', 'test_cf_testcase.Test3', ]) def test_conn_prep(self): self.plugin.bind_host = None (parent_conn, child_conn) = self.plugin._prepConns() (parent_pipe, child_pipe) = multiprocessing.Pipe() self.assertIsInstance(parent_conn, type(parent_pipe)) self.assertIsInstance(child_conn, type(child_pipe)) self.plugin.bind_host = "127.0.0.1" self.plugin.bind_port = 0 (parent_conn, child_conn) = self.plugin._prepConns() self.assertIsInstance(parent_conn, connection.Listener) self.assertIsInstance(child_conn, tuple) self.assertEqual(parent_conn.address, child_conn[:2]) def test_conn_accept(self): (parent_conn, child_conn) = multiprocessing.Pipe() self.assertEqual(self.plugin._acceptConns(parent_conn), parent_conn) listener = connection.Listener(('127.0.0.1', 0)) with self.assertRaises(RuntimeError): self.plugin._acceptConns(listener) def fake_client(address): client = connection.Client(address) time.sleep(self.plugin.testRunTimeout) client.close() t = threading.Thread(target=fake_client, args=(listener.address, )) t.start() conn = self.plugin._acceptConns(listener) self.assertTrue(hasattr(conn, "send")) self.assertTrue(hasattr(conn, "recv")) t.join()