aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting/tests/unit/core
diff options
context:
space:
mode:
Diffstat (limited to 'xtesting/tests/unit/core')
-rw-r--r--xtesting/tests/unit/core/test_behaveframework.py12
-rw-r--r--xtesting/tests/unit/core/test_feature.py50
-rw-r--r--xtesting/tests/unit/core/test_robotframework.py12
-rw-r--r--xtesting/tests/unit/core/test_unit.py16
4 files changed, 57 insertions, 33 deletions
diff --git a/xtesting/tests/unit/core/test_behaveframework.py b/xtesting/tests/unit/core/test_behaveframework.py
index 7cfcdec7..cd39f139 100644
--- a/xtesting/tests/unit/core/test_behaveframework.py
+++ b/xtesting/tests/unit/core/test_behaveframework.py
@@ -119,10 +119,10 @@ class RunTesting(unittest.TestCase):
html_file = os.path.join(self.test.res_dir, 'output.html')
args_list = [
'--junit',
- '--junit-directory={}'.format(self.test.res_dir),
- '--format=json', '--outfile={}'.format(self.test.json_file),
+ f'--junit-directory={self.test.res_dir}',
+ '--format=json', f'--outfile={self.test.json_file}',
'--format=behave_html_formatter:HTMLFormatter',
- '--outfile={}'.format(html_file),
+ f'--outfile={html_file}',
'--tags='+','.join(self.tags)]
args_list.append('foo')
args[0].assert_called_once_with(args_list)
@@ -152,10 +152,10 @@ class RunTesting(unittest.TestCase):
html_file = os.path.join(self.test.res_dir, 'output.html')
args_list = [
'--junit',
- '--junit-directory={}'.format(self.test.res_dir),
- '--format=json', '--outfile={}'.format(self.test.json_file),
+ f'--junit-directory={self.test.res_dir}',
+ '--format=json', f'--outfile={self.test.json_file}',
'--format=behave_html_formatter:HTMLFormatter',
- '--outfile={}'.format(html_file),
+ f'--outfile={html_file}',
'--tags='+','.join(self.tags)]
if console:
args_list += ['--format=pretty', '--outfile=-']
diff --git a/xtesting/tests/unit/core/test_feature.py b/xtesting/tests/unit/core/test_feature.py
index 9e5e109c..76ae2c1c 100644
--- a/xtesting/tests/unit/core/test_feature.py
+++ b/xtesting/tests/unit/core/test_feature.py
@@ -120,7 +120,7 @@ class BashFeatureTesting(FeatureTestingBase):
def test_run_ko1(self, *args):
with mock.patch('builtins.open', mock.mock_open()) as mopen:
self._test_run(testcase.TestCase.EX_RUN_ERROR)
- mopen.assert_called_once_with(self._output_file, "w")
+ mopen.assert_called_once_with(self._output_file, "w", encoding='utf-8')
args[0].assert_called_once_with(
self._cmd, shell=True, stderr=mock.ANY, stdout=mock.ANY)
args[1].assert_called_once_with(self.feature.res_dir)
@@ -136,8 +136,12 @@ class BashFeatureTesting(FeatureTestingBase):
args[0].configure_mock(**attrs)
with mock.patch('builtins.open', mock.mock_open()) as mopen:
self._test_run(testcase.TestCase.EX_RUN_ERROR)
- self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls)
- self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'w', encoding='utf-8'),
+ mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'r', encoding='utf-8'),
+ mopen.mock_calls)
args[0].assert_called_once_with(
self._cmd, shell=True, stderr=mock.ANY, stdout=mock.ANY)
args[1].assert_called_once_with(self.feature.res_dir)
@@ -159,8 +163,12 @@ class BashFeatureTesting(FeatureTestingBase):
args[1].configure_mock(**attrs)
with mock.patch('builtins.open', mock.mock_open()) as mopen:
self._test_run_max_duration(testcase.TestCase.EX_RUN_ERROR)
- self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls)
- self.assertNotIn(mock.call(self._output_file, 'r'), mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'w', encoding='utf-8'),
+ mopen.mock_calls)
+ self.assertNotIn(
+ mock.call(self._output_file, 'r', encoding='utf-8'),
+ mopen.mock_calls)
args[1].assert_called_once_with(
self._cmd, shell=True, stderr=mock.ANY, stdout=mock.ANY)
wait.assert_called_once_with(timeout=FeatureTestingBase._max_duration)
@@ -178,8 +186,12 @@ class BashFeatureTesting(FeatureTestingBase):
args[0].configure_mock(**attrs)
with mock.patch('builtins.open', mock.mock_open()) as mopen:
self._test_run(testcase.TestCase.EX_OK)
- self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls)
- self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'w', encoding='utf-8'),
+ mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'r', encoding='utf-8'),
+ mopen.mock_calls)
args[0].assert_called_once_with(
self._cmd, shell=True, stderr=mock.ANY, stdout=mock.ANY)
args[1].assert_called_once_with(self.feature.res_dir)
@@ -195,8 +207,12 @@ class BashFeatureTesting(FeatureTestingBase):
args[0].configure_mock(**attrs)
with mock.patch('builtins.open', mock.mock_open()) as mopen:
self._test_run_console(True, testcase.TestCase.EX_OK)
- self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls)
- self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'w', encoding='utf-8'),
+ mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'r', encoding='utf-8'),
+ mopen.mock_calls)
args[0].assert_called_once_with(
self._cmd, shell=True, stderr=mock.ANY, stdout=mock.ANY)
args[1].assert_called_once_with(self.feature.res_dir)
@@ -212,8 +228,12 @@ class BashFeatureTesting(FeatureTestingBase):
args[0].configure_mock(**attrs)
with mock.patch('builtins.open', mock.mock_open()) as mopen:
self._test_run_console(False, testcase.TestCase.EX_OK)
- self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls)
- self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'w', encoding='utf-8'),
+ mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'r', encoding='utf-8'),
+ mopen.mock_calls)
args[0].assert_called_once_with(
self._cmd, shell=True, stderr=mock.ANY, stdout=mock.ANY)
args[1].assert_called_once_with(self.feature.res_dir)
@@ -230,8 +250,12 @@ class BashFeatureTesting(FeatureTestingBase):
args[0].configure_mock(**attrs)
with mock.patch('builtins.open', mock.mock_open()) as mopen:
self._test_run_console(False, testcase.TestCase.EX_OK)
- self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls)
- self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'w', encoding='utf-8'),
+ mopen.mock_calls)
+ self.assertIn(
+ mock.call(self._output_file, 'r', encoding='utf-8'),
+ mopen.mock_calls)
args[0].assert_called_once_with(
self._cmd, shell=True, stderr=mock.ANY, stdout=mock.ANY)
args[1].assert_called_once_with(self.feature.res_dir)
diff --git a/xtesting/tests/unit/core/test_robotframework.py b/xtesting/tests/unit/core/test_robotframework.py
index bc05f523..f36625e6 100644
--- a/xtesting/tests/unit/core/test_robotframework.py
+++ b/xtesting/tests/unit/core/test_robotframework.py
@@ -140,9 +140,9 @@ class GenerateReportTesting(unittest.TestCase):
args[0].assert_called_once_with(self.test.xml_file)
args[1].assert_called_once_with(args[0].return_value)
args[2].assert_called_once_with(
- report='{}/report.html'.format(self.test.res_dir),
- log='{}/log.html'.format(self.test.res_dir),
- xunit='{}/xunit.xml'.format(self.test.res_dir))
+ report=f'{self.test.res_dir}/report.html',
+ log=f'{self.test.res_dir}/log.html',
+ xunit=f'{self.test.res_dir}/xunit.xml')
@mock.patch('robot.reporting.resultwriter.ResultWriter.write_results',
return_value=0)
@@ -154,9 +154,9 @@ class GenerateReportTesting(unittest.TestCase):
args[0].assert_called_once_with(self.test.xml_file)
args[1].assert_called_once_with(args[0].return_value)
args[2].assert_called_once_with(
- report='{}/report.html'.format(self.test.res_dir),
- log='{}/log.html'.format(self.test.res_dir),
- xunit='{}/xunit.xml'.format(self.test.res_dir))
+ report=f'{self.test.res_dir}/report.html',
+ log=f'{self.test.res_dir}/log.html',
+ xunit=f'{self.test.res_dir}/xunit.xml')
class RunTesting(unittest.TestCase):
diff --git a/xtesting/tests/unit/core/test_unit.py b/xtesting/tests/unit/core/test_unit.py
index 9e5f1321..5cce83be 100644
--- a/xtesting/tests/unit/core/test_unit.py
+++ b/xtesting/tests/unit/core/test_unit.py
@@ -54,7 +54,7 @@ class SuiteTesting(unittest.TestCase):
['subunit2junitxml'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
mock_open.assert_called_once_with(
- '{}/results.xml'.format(self.psrunner.res_dir), 'w')
+ f'{self.psrunner.res_dir}/results.xml', 'w', encoding='utf-8')
@mock.patch('subprocess.Popen')
def test_generate_xunit_ok(self, *args):
@@ -69,7 +69,7 @@ class SuiteTesting(unittest.TestCase):
['subunit2junitxml'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
mock_open.assert_called_once_with(
- '{}/results.xml'.format(self.psrunner.res_dir), 'w')
+ f'{self.psrunner.res_dir}/results.xml', 'w', encoding='utf-8')
@mock.patch('subprocess.check_output', side_effect=Exception)
def test_generate_html_ko(self, *args):
@@ -78,7 +78,7 @@ class SuiteTesting(unittest.TestCase):
self.psrunner.generate_html(stream)
args[0].assert_called_once_with(
['subunit2html', stream,
- '{}/results.html'.format(self.psrunner.res_dir)])
+ f'{self.psrunner.res_dir}/results.html'])
@mock.patch('subprocess.check_output')
def test_generate_html_ok(self, *args):
@@ -86,7 +86,7 @@ class SuiteTesting(unittest.TestCase):
self.psrunner.generate_html(stream)
args[0].assert_called_once_with(
['subunit2html', stream,
- '{}/results.html'.format(self.psrunner.res_dir)])
+ f'{self.psrunner.res_dir}/results.html'])
@mock.patch('xtesting.core.unit.Suite.generate_html')
@mock.patch('xtesting.core.unit.Suite.generate_xunit')
@@ -98,14 +98,14 @@ class SuiteTesting(unittest.TestCase):
with mock.patch('builtins.open', mock.mock_open()) as m_open:
self.assertEqual(self.psrunner.run(), status)
m_open.assert_called_once_with(
- '{}/subunit_stream'.format(self.psrunner.res_dir), 'wb')
+ f'{self.psrunner.res_dir}/subunit_stream', 'wb')
self.assertEqual(self.psrunner.is_successful(), result)
args[0].assert_called_once_with(self.psrunner.suite)
args[1].assert_not_called()
args[2].assert_called_once_with(mock.ANY)
args[3].assert_called_once_with(mock.ANY)
args[4].assert_called_once_with(
- '{}/subunit_stream'.format(self.psrunner.res_dir))
+ f'{self.psrunner.res_dir}/subunit_stream')
@mock.patch('xtesting.core.unit.Suite.generate_html')
@mock.patch('xtesting.core.unit.Suite.generate_xunit')
@@ -117,14 +117,14 @@ class SuiteTesting(unittest.TestCase):
with mock.patch('builtins.open', mock.mock_open()) as m_open:
self.assertEqual(self.psrunner.run(name=name), status)
m_open.assert_called_once_with(
- '{}/subunit_stream'.format(self.psrunner.res_dir), 'wb')
+ f'{self.psrunner.res_dir}/subunit_stream', 'wb')
self.assertEqual(self.psrunner.is_successful(), result)
args[0].assert_called_once_with(self.psrunner.suite)
args[1].assert_called_once_with()
args[2].assert_called_once_with(mock.ANY)
args[3].assert_called_once_with(mock.ANY)
args[4].assert_called_once_with(
- '{}/subunit_stream'.format(self.psrunner.res_dir))
+ f'{self.psrunner.res_dir}/subunit_stream')
@mock.patch('xtesting.core.unit.Suite.generate_html')
@mock.patch('xtesting.core.unit.Suite.generate_xunit')