Skip to content
Snippets Groups Projects
Commit ad1b4703 authored by Stefano Borini's avatar Stefano Borini
Browse files

py27 compat

parent 481ce0b8
No related branches found
No related tags found
1 merge request!108Introduced log file option
...@@ -3,6 +3,8 @@ import subprocess ...@@ -3,6 +3,8 @@ import subprocess
import os import os
from contextlib import contextmanager from contextlib import contextmanager
import six
from force_bdss.tests import fixtures from force_bdss.tests import fixtures
...@@ -43,16 +45,16 @@ class TestExecution(unittest.TestCase): ...@@ -43,16 +45,16 @@ class TestExecution(unittest.TestCase):
with self.assertRaises(subprocess.CalledProcessError): with self.assertRaises(subprocess.CalledProcessError):
subprocess.check_call( subprocess.check_call(
["force_bdss", "test_csv_v2.json"], ["force_bdss", "test_csv_v2.json"],
stdout=subprocess.DEVNULL, stdout=os.devnull,
stderr=subprocess.DEVNULL) stderr=os.devnull)
def test_corrupted_file_input(self): def test_corrupted_file_input(self):
with cd(fixtures.dirpath()): with cd(fixtures.dirpath()):
with self.assertRaises(subprocess.CalledProcessError): with self.assertRaises(subprocess.CalledProcessError):
subprocess.check_call( subprocess.check_call(
["force_bdss", "test_csv_corrupted.json"], ["force_bdss", "test_csv_corrupted.json"],
stdout=subprocess.DEVNULL, stdout=os.devnull,
stderr=subprocess.DEVNULL) stderr=os.devnull)
if __name__ == '__main__': if __name__ == '__main__':
......
import unittest import unittest
import testfixtures import testfixtures
import six
from force_bdss.tests.probe_classes.factory_registry_plugin import \ from force_bdss.tests.probe_classes.factory_registry_plugin import \
ProbeFactoryRegistryPlugin ProbeFactoryRegistryPlugin
...@@ -49,7 +50,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ...@@ -49,7 +50,8 @@ class TestCoreEvaluationDriver(unittest.TestCase):
driver = CoreEvaluationDriver( driver = CoreEvaluationDriver(
application=self.mock_application) application=self.mock_application)
with testfixtures.LogCapture(): with testfixtures.LogCapture():
with self.assertRaisesRegex( with six.assertRaisesRegex(
self,
RuntimeError, RuntimeError,
"The number of data values returned by the MCO"): "The number of data values returned by the MCO"):
driver.application_started() driver.application_started()
...@@ -66,7 +68,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ...@@ -66,7 +68,8 @@ class TestCoreEvaluationDriver(unittest.TestCase):
driver = CoreEvaluationDriver( driver = CoreEvaluationDriver(
application=self.mock_application) application=self.mock_application)
with testfixtures.LogCapture(): with testfixtures.LogCapture():
with self.assertRaisesRegex( with six.assertRaisesRegex(
self,
RuntimeError, RuntimeError,
"The number of data values \(1 values\)" "The number of data values \(1 values\)"
" returned by 'test_data_source' does not match" " returned by 'test_data_source' does not match"
...@@ -87,7 +90,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ...@@ -87,7 +90,8 @@ class TestCoreEvaluationDriver(unittest.TestCase):
application=self.mock_application, application=self.mock_application,
) )
with testfixtures.LogCapture(): with testfixtures.LogCapture():
with self.assertRaisesRegex( with six.assertRaisesRegex(
self,
RuntimeError, RuntimeError,
"The number of data values \(1 values\)" "The number of data values \(1 values\)"
" returned by 'test_data_source' does not match" " returned by 'test_data_source' does not match"
...@@ -107,7 +111,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ...@@ -107,7 +111,8 @@ class TestCoreEvaluationDriver(unittest.TestCase):
application=self.mock_application, application=self.mock_application,
) )
with testfixtures.LogCapture(): with testfixtures.LogCapture():
with self.assertRaisesRegex( with six.assertRaisesRegex(
self,
RuntimeError, RuntimeError,
"The number of data values \(1 values\)" "The number of data values \(1 values\)"
" returned by 'test_kpi_calculator' does not match" " returned by 'test_kpi_calculator' does not match"
...@@ -130,7 +135,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ...@@ -130,7 +135,8 @@ class TestCoreEvaluationDriver(unittest.TestCase):
) )
with testfixtures.LogCapture(): with testfixtures.LogCapture():
with self.assertRaisesRegex( with six.assertRaisesRegex(
self,
RuntimeError, RuntimeError,
"The number of data values \(1 values\)" "The number of data values \(1 values\)"
" returned by 'test_kpi_calculator' does not match" " returned by 'test_kpi_calculator' does not match"
...@@ -164,7 +170,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ...@@ -164,7 +170,8 @@ class TestCoreEvaluationDriver(unittest.TestCase):
) )
with testfixtures.LogCapture(): with testfixtures.LogCapture():
with self.assertRaisesRegex( with six.assertRaisesRegex(
self,
RuntimeError, RuntimeError,
"The length of the slots is not equal to the length of" "The length of the slots is not equal to the length of"
" the slot map"): " the slot map"):
...@@ -177,7 +184,8 @@ class TestCoreEvaluationDriver(unittest.TestCase): ...@@ -177,7 +184,8 @@ class TestCoreEvaluationDriver(unittest.TestCase):
) )
with testfixtures.LogCapture(): with testfixtures.LogCapture():
with self.assertRaisesRegex( with six.assertRaisesRegex(
self,
RuntimeError, RuntimeError,
"Unable to find requested name 'blap' in available" "Unable to find requested name 'blap' in available"
" data values."): " data values."):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment