From 20be11ff035f3df49ce97c80577a2778bc9dbafe Mon Sep 17 00:00:00 2001 From: Mikko Korpela Date: Sun, 28 Jan 2024 20:41:49 +0200 Subject: [PATCH] test for include --- tests/test_testlevelsplit_include.py | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/test_testlevelsplit_include.py diff --git a/tests/test_testlevelsplit_include.py b/tests/test_testlevelsplit_include.py new file mode 100644 index 00000000..e55d5ee0 --- /dev/null +++ b/tests/test_testlevelsplit_include.py @@ -0,0 +1,53 @@ +import os +import sys +import tempfile +import textwrap +import unittest +import shutil +import subprocess + + + +class PabotPassJsonUsingVariableOptionTests(unittest.TestCase): + def setUp(self): + self.tmpdir = tempfile.mkdtemp() + file_path = f"{self.tmpdir}/test.robot" + with open(file_path, "w") as robot_file: + robot_file.write( + textwrap.dedent(""" +*** Test Cases *** +Testing 1 + [Tags] tag + Log hello + +Testing 2 + [Tags] tag + Log world +""")) + + process = subprocess.Popen( + [ + sys.executable, + "-m" "pabot.pabot", + "--testlevelsplit", + "--verbose", + "--include", + "tag", + f"{self.tmpdir}/test.robot", + ], + cwd=self.tmpdir, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + + self.stdout, self.stderr = process.communicate() + + def test_stdout_should_display_passed_test(self): + first = b"Testing 1 | PASS |" + second = b"Testing 2 | PASS |" + self.assertEqual(self.stdout.count(first), 1, self.stdout) + self.assertEqual(self.stdout.count(second), 1, self.stdout) + self.assertIn(b"PASSED Test", self.stdout, self.stderr) + + def tearDown(self): + shutil.rmtree(self.tmpdir)