From ad1b4703b3f1560f99dec15b44d2c8b673fff592 Mon Sep 17 00:00:00 2001 From: Stefano Borini <sborini@enthought.com> Date: Mon, 23 Apr 2018 17:30:12 +0100 Subject: [PATCH] py27 compat --- force_bdss/cli/tests/test_execution.py | 10 +++++---- .../tests/test_core_evaluation_driver.py | 22 +++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/force_bdss/cli/tests/test_execution.py b/force_bdss/cli/tests/test_execution.py index 50cf180..d427e15 100644 --- a/force_bdss/cli/tests/test_execution.py +++ b/force_bdss/cli/tests/test_execution.py @@ -3,6 +3,8 @@ import subprocess import os from contextlib import contextmanager +import six + from force_bdss.tests import fixtures @@ -43,16 +45,16 @@ class TestExecution(unittest.TestCase): with self.assertRaises(subprocess.CalledProcessError): subprocess.check_call( ["force_bdss", "test_csv_v2.json"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + stdout=os.devnull, + stderr=os.devnull) def test_corrupted_file_input(self): with cd(fixtures.dirpath()): with self.assertRaises(subprocess.CalledProcessError): subprocess.check_call( ["force_bdss", "test_csv_corrupted.json"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + stdout=os.devnull, + stderr=os.devnull) if __name__ == '__main__': diff --git a/force_bdss/tests/test_core_evaluation_driver.py b/force_bdss/tests/test_core_evaluation_driver.py index 141c8a3..a6084e7 100644 --- a/force_bdss/tests/test_core_evaluation_driver.py +++ b/force_bdss/tests/test_core_evaluation_driver.py @@ -1,6 +1,7 @@ import unittest import testfixtures +import six from force_bdss.tests.probe_classes.factory_registry_plugin import \ ProbeFactoryRegistryPlugin @@ -49,7 +50,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): driver = CoreEvaluationDriver( application=self.mock_application) with testfixtures.LogCapture(): - with self.assertRaisesRegex( + with six.assertRaisesRegex( + self, RuntimeError, "The number of data values returned by the MCO"): driver.application_started() @@ -66,7 +68,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): driver = CoreEvaluationDriver( application=self.mock_application) with testfixtures.LogCapture(): - with self.assertRaisesRegex( + with six.assertRaisesRegex( + self, RuntimeError, "The number of data values \(1 values\)" " returned by 'test_data_source' does not match" @@ -87,7 +90,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): application=self.mock_application, ) with testfixtures.LogCapture(): - with self.assertRaisesRegex( + with six.assertRaisesRegex( + self, RuntimeError, "The number of data values \(1 values\)" " returned by 'test_data_source' does not match" @@ -107,7 +111,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): application=self.mock_application, ) with testfixtures.LogCapture(): - with self.assertRaisesRegex( + with six.assertRaisesRegex( + self, RuntimeError, "The number of data values \(1 values\)" " returned by 'test_kpi_calculator' does not match" @@ -130,7 +135,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ) with testfixtures.LogCapture(): - with self.assertRaisesRegex( + with six.assertRaisesRegex( + self, RuntimeError, "The number of data values \(1 values\)" " returned by 'test_kpi_calculator' does not match" @@ -164,7 +170,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ) with testfixtures.LogCapture(): - with self.assertRaisesRegex( + with six.assertRaisesRegex( + self, RuntimeError, "The length of the slots is not equal to the length of" " the slot map"): @@ -177,7 +184,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ) with testfixtures.LogCapture(): - with self.assertRaisesRegex( + with six.assertRaisesRegex( + self, RuntimeError, "Unable to find requested name 'blap' in available" " data values."): -- GitLab