Skip to content

Commit

Permalink
Remove usage of deprecated method: assertRegexpMatches
Browse files Browse the repository at this point in the history
  • Loading branch information
lresende committed May 28, 2018
1 parent d0546a9 commit 720f7e5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions enterprise_gateway/itests/test_python_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PythonKernelBaseTestCase(object):

def test_hello_world(self):
result = self.kernel.execute("print('Hello World')")
self.assertRegexpMatches(result, 'Hello World')
self.assertRegex(result, 'Hello World')

def test_restart(self):

Expand All @@ -25,7 +25,7 @@ def test_restart(self):
self.assertTrue(self.kernel.restart())

error_result = self.kernel.execute("y = x + 1")
self.assertRegexpMatches(error_result, 'NameError')
self.assertRegex(error_result, 'NameError')

def test_interrupt(self):

Expand All @@ -52,7 +52,7 @@ def test_interrupt(self):
interrupted_result = self.kernel.execute(interrupted_code)

# Ensure the result indicates an interrupt occurred
self.assertRegexpMatches(interrupted_result, 'KeyboardInterrupt')
self.assertRegex(interrupted_result, 'KeyboardInterrupt')

# Wait for thread to terminate - should be terminated already
self.kernel.terminate_interrupt_thread()
Expand All @@ -70,23 +70,23 @@ class PythonKernelBaseYarnTestCase(PythonKernelBaseTestCase):

def test_get_application_id(self):
result = self.kernel.execute("print(sc.applicationId)")
self.assertRegexpMatches(result, 'application_')
self.assertRegex(result, 'application_')

def test_get_spark_version(self):
result = self.kernel.execute("sc.version")
self.assertRegexpMatches(result, '2.1.*')
self.assertRegex(result, '2.1.*')

def test_get_resource_manager(self):
result = self.kernel.execute("sc.getConf().get('spark.master')")
self.assertRegexpMatches(result, 'yarn.*')
self.assertRegex(result, 'yarn.*')

def test_get_deploy_mode(self):
result = self.kernel.execute("sc.getConf().get('spark.submit.deployMode')")
self.assertRegexpMatches(result, '(cluster|client)')
self.assertRegex(result, '(cluster|client)')

def test_get_host_address(self):
result = self.kernel.execute("print(sc.getConf().get('spark.driver.host'))")
self.assertRegexpMatches(result, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
self.assertRegex(result, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')


class TestPythonKernelLocal(unittest.TestCase, PythonKernelBaseTestCase):
Expand Down
14 changes: 7 additions & 7 deletions enterprise_gateway/itests/test_r_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RKernelBaseTestCase(object):

def test_hello_world(self):
result = self.kernel.execute('print("Hello World", quote = FALSE)')
self.assertRegexpMatches(result, 'Hello World')
self.assertRegex(result, 'Hello World')

def test_restart(self):

Expand All @@ -25,7 +25,7 @@ def test_restart(self):
self.assertTrue(self.kernel.restart())

error_result = self.kernel.execute("y = x + 1")
self.assertRegexpMatches(error_result, 'Error in eval')
self.assertRegex(error_result, 'Error in eval')

def test_interrupt(self):

Expand Down Expand Up @@ -69,23 +69,23 @@ class RKernelBaseYarnTestCase(RKernelBaseTestCase):

def test_get_application_id(self):
result = self.kernel.execute('SparkR:::callJMethod(SparkR:::callJMethod(sc, "sc"), "applicationId")')
self.assertRegexpMatches(result, 'application_')
self.assertRegex(result, 'application_')

def test_get_spark_version(self):
result = self.kernel.execute("sparkR.version()")
self.assertRegexpMatches(result, '2.1')
self.assertRegex(result, '2.1')

def test_get_resource_manager(self):
result = self.kernel.execute('unlist(sparkR.conf("spark.master"))')
self.assertRegexpMatches(result, 'yarn')
self.assertRegex(result, 'yarn')

def test_get_deploy_mode(self):
result = self.kernel.execute('unlist(sparkR.conf("spark.submit.deployMode"))')
self.assertRegexpMatches(result, '(cluster|client)')
self.assertRegex(result, '(cluster|client)')

def test_get_host_address(self):
result = self.kernel.execute('unlist(sparkR.conf("spark.driver.host"))')
self.assertRegexpMatches(result, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
self.assertRegex(result, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')


class TestRKernelLocal(unittest.TestCase, RKernelBaseTestCase):
Expand Down
16 changes: 8 additions & 8 deletions enterprise_gateway/itests/test_scala_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ScalaKernelBaseTestCase(object):

def test_hello_world(self):
result = self.kernel.execute('println("Hello World")')
self.assertRegexpMatches(result, 'Hello World')
self.assertRegex(result, 'Hello World')

def test_restart(self):

Expand All @@ -25,7 +25,7 @@ def test_restart(self):
self.assertTrue(self.kernel.restart())

error_result = self.kernel.execute("var y = x + 1")
self.assertRegexpMatches(error_result, 'Compile Error')
self.assertRegex(error_result, 'Compile Error')

def test_interrupt(self):

Expand All @@ -51,7 +51,7 @@ def test_interrupt(self):
interrupted_result = self.kernel.execute(interrupted_code)

# Ensure the result indicates an interrupt occurred
self.assertRegexpMatches(interrupted_result, 'java.lang.InterruptedException')
self.assertRegex(interrupted_result, 'java.lang.InterruptedException')

# Wait for thread to terminate - should be terminated already
self.kernel.terminate_interrupt_thread()
Expand All @@ -69,23 +69,23 @@ class ScalaKernelBaseYarnTestCase(ScalaKernelBaseTestCase):

def test_get_application_id(self):
result = self.kernel.execute('sc.applicationId')
self.assertRegexpMatches(result, 'application_')
self.assertRegex(result, 'application_')

def test_get_spark_version(self):
result = self.kernel.execute("sc.version")
self.assertRegexpMatches(result, '2.1')
self.assertRegex(result, '2.1')

def test_get_resource_manager(self):
result = self.kernel.execute('sc.getConf.get("spark.master")')
self.assertRegexpMatches(result, 'yarn')
self.assertRegex(result, 'yarn')

def test_get_deploy_mode(self):
result = self.kernel.execute('sc.getConf.get("spark.submit.deployMode")')
self.assertRegexpMatches(result, '(cluster|client)')
self.assertRegex(result, '(cluster|client)')

def test_get_host_address(self):
result = self.kernel.execute('sc.getConf.get("spark.driver.host")')
self.assertRegexpMatches(result, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
self.assertRegex(result, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')


class TestScalaKernelLocal(unittest.TestCase, ScalaKernelBaseTestCase):
Expand Down

0 comments on commit 720f7e5

Please sign in to comment.