Repository: AcademySoftwareFoundation/rez (language: python)

Issue:
Test command doesn't run when defined as list
I've found that if I define a test command as a list like so:
```
tests={
    "unit": {
        "command": ["python3", "-m", "pytest", "{root}/tests"],
        "requires": ["pytest"],
        "run_on": ["default"]
    }
}
```
which I believe should be allowed (https://github.com/AcademySoftwareFoundation/rez/wiki/Package-Definition-Guide#tests), when I run rez test, the command is never run and the command reports a success status, even if running the tests would result in a failure.

I think this is caused because rez test constructs a map object [here](https://github.com/AcademySoftwareFoundation/rez/blob/master/src/rez/package_test.py#L395) if the test command is a list, then evaluates it [here](https://github.com/AcademySoftwareFoundation/rez/blob/master/src/rez/package_test.py#L406) which exhausts the iterator. The iterator then gets passed down, rez runs a blank shell command, and thinks everything is fine.

**Environment**
* Ubuntu LTS 22.04
* Rez 2.112.0
* Rez python version 3.10.12

**To Reproduce**
Define a package like so:
```
name = "test_package"
version = "1.0.0"
build_command = ""
tests={
    "fail": {
        "command": "exit 1"
    },
    "fail_lst": {
        "command": ["exit", "1"]
    }
}
```
Build the package.
Run `rez test test_package fail`
Run `rez test test_package fail_lst`

**Expected behavior**
I would expect both of the rez test commands to report the following in their output:
```
Running test command: exit 1
18:17:04 WARNING  Test command exited with code 1


Test results:
--------------------------------------------------------------------------------
0 succeeded, 1 failed, 0 skipped
```

**Actual behavior**
`rez test test_package fail_lst` does not do this, it reports that the test passed:
```
Running test command: exit 1


Test results:
--------------------------------------------------------------------------------
1 succeeded, 0 failed, 0 skipped
```



Discussion / hints:
@bhawkyard1 sorry for the delay. This will be fixed in the next release.

Fix patch:
diff --git a/docs/source/package_definition.rst b/docs/source/package_definition.rst
index b4ad4ab3d..80e2cb8d1 100644
--- a/docs/source/package_definition.rst
+++ b/docs/source/package_definition.rst
@@ -854,13 +854,14 @@ the data type, and includes a code snippet.
 
       tests = {
          "unit": "python -m unittest discover -s {root}/python/tests",
+         "unit-as-list": ["python", "-m", "unittest", "discover", "-s", "{root}/python/tests"],
          "lint": {
                "command": "pylint mymodule",
                "requires": ["pylint"],
                "run_on": ["default", "pre_release"]
          },
          "maya_CI": {
-               "command": "python {root}/ci_tests/maya.py",
+               "command": ["python", "{root}/ci_tests/maya.py"],
                "on_variants": {
                   "type": "requires",
                   "value": ["maya"]


Test patch:
diff --git a/src/rez/package_test.py b/src/rez/package_test.py
index 3c85882d1..f0ad9d133 100644
--- a/src/rez/package_test.py
+++ b/src/rez/package_test.py
@@ -394,7 +394,9 @@ def run_test(self, test_name, extra_test_args=None):
             if isinstance(command, str):
                 command = variant.format(command)
             else:
-                command = map(variant.format, command)
+                # Note that we convert the iterator to a list to
+                # make sure that we can consume the variable more than once.
+                command = [x for x in map(variant.format, command)]
 
             if extra_test_args:
                 if isinstance(command, str):