Skip to content

Commit

Permalink
Add test to wildcarded test command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ni-g-3l committed Nov 5, 2024
1 parent fc112f4 commit be3fac1
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions src/rez/tests/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,111 @@ def _get_test_result(self, runner, test_name):
(result for result in runner.test_results.test_results if result.get("test_name") == test_name),
None
)

def test_wildcard_01(self):
"""package.py unit tests are correctly found with a wildcard then run in a testing environment"""
self.inject_python_repo()
context = ResolvedContext(["testing_obj", "python"])
# This will get us more code coverage :)
self.inject_python_repo()
runner = PackageTestRunner(
package_request="testing_obj",
package_paths=context.package_paths,
)

test_names = runner.find_requested_test_names(["command_as_*"])
self.assertEqual(2, len(test_names))

for test_name in test_names:
runner.run_test(test_name)

self.assertEqual(runner.test_results.num_tests, 2)

self.assertEqual(
self._get_test_result(runner, "command_as_string_success")["status"],
"success",
"command_as_string_success did not succeed",
)
self.assertEqual(
self._get_test_result(runner, "command_as_string_fail")["status"],
"failed",
"command_as_string_fail did not fail",
)

def test_wildcard_02(self):
"""package.py unit tests are correctly found with a wildcard + a package name then run in a testing environment"""
self.inject_python_repo()
context = ResolvedContext(["testing_obj", "python"])
# This will get us more code coverage :)
self.inject_python_repo()
runner = PackageTestRunner(
package_request="testing_obj",
package_paths=context.package_paths,

)

test_names = runner.find_requested_test_names(["command_as_*", "check_car_ideas"])
self.assertEqual(3, len(test_names))

for test_name in test_names:
runner.run_test(test_name)

self.assertEqual(runner.test_results.num_tests, 3)

self.assertEqual(
self._get_test_result(runner, "check_car_ideas")["status"],
"success",
"check_car_ideas did not succeed",
)

self.assertEqual(
self._get_test_result(runner, "command_as_string_success")["status"],
"success",
"command_as_string_success did not succeed",
)
self.assertEqual(
self._get_test_result(runner, "command_as_string_fail")["status"],
"failed",
"command_as_string_fail did not fail",
)

def test_wildcard_03(self):
"""package.py unit tests are correctly found with a wildcard equivalent to 'default' then run in a testing environment"""
self.inject_python_repo()
context = ResolvedContext(["testing_obj", "python"])
# This will get us more code coverage :)
self.inject_python_repo()
runner = PackageTestRunner(
package_request="testing_obj",
package_paths=context.package_paths,

)

test_names = runner.find_requested_test_names(["*"])
self.assertEqual(4, len(test_names))

for test_name in test_names:
runner.run_test(test_name)

self.assertEqual(runner.test_results.num_tests, 4)

self.assertEqual(
self._get_test_result(runner, "check_car_ideas")["status"],
"success",
"check_car_ideas did not succeed",
)
self.assertEqual(
self._get_test_result(runner, "move_meeting_to_noon")["status"],
"failed",
"move_meeting_to_noon did not fail",
)
self.assertEqual(
self._get_test_result(runner, "command_as_string_success")["status"],
"success",
"command_as_string_success did not succeed",
)
self.assertEqual(
self._get_test_result(runner, "command_as_string_fail")["status"],
"failed",
"command_as_string_fail did not fail",
)

0 comments on commit be3fac1

Please sign in to comment.