spark-test commented on code in PR #60617:
URL: https://github.com/apache/spark/pull/60617#discussion_r4632948050
##########
dev/sparktestsupport/tests/test_utils.py:
##########
@@ -139,6 +141,30 @@ def test_core_and_sql_without_deduplication(self):
self.assertCountEqual([module.name for module in result], expected)
+class ParseTestModulesTests(unittest.TestCase):
+ def test_resolves_known_names_in_all_modules_order(self):
+ self.assertEqual(
+ parse_test_modules("graphx,core,graphx"),
+ [modules.core, modules.graphx],
+ )
+
+ def test_unknown_names_keep_input_order(self):
+ with self.assertRaises(ArgumentTypeError) as error:
+
parse_test_modules("core,does-not-exist,also-missing,does-not-exist")
+ message = str(error.exception)
+ self.assertIn("unrecognized module(s): 'does-not-exist',
'also-missing'", message)
+ supported = message.split("Supported modules: ", 1)[1]
Review Comment:
**Nit (P3):** This checks only that the message contains `unrecognized
module(s): 'does-not-exist', 'also-missing'`, so it cannot tell whether the
repeated `does-not-exist` in this test's input is listed once. If
`dict.fromkeys` were dropped from line 133 of `dev/sparktestsupport/utils.py`,
the error would read `unrecognized module(s): 'does-not-exist', 'also-missing',
'does-not-exist'. Supported modules: ...`, which still contains that text. In a
repro with that change, `ParseTestModulesTests` and the
`sparktestsupport.utils` doctests all still passed. The effect on contributors
would only be cosmetic, such as `--modules typo,typo` reporting `'typo',
'typo'`, but the test reads as if it covered the deduplication. Comparing the
whole text before `Supported modules: ` closes the gap: with the change below,
the copy without deduplication fails this test, and the current code still
passes.
```suggestion
unknown, supported = message.split("Supported modules: ", 1)
self.assertEqual(unknown, "unrecognized module(s): 'does-not-exist',
'also-missing'. ")
```
**Verification:**
- **Regression:** `test_unknown_names_keep_input_order`, with its input
`core,does-not-exist,also-missing,does-not-exist`, passes against the current
`parse_test_modules` and fails against modified copies of the function that
change the error text before `Supported modules: `: one that keeps duplicate
unknown names, whose error would read `unrecognized module(s):
'does-not-exist', 'also-missing', 'does-not-exist'`, one that adds text before
`unrecognized module(s):`, and one that reports unknown names in sorted order.
It also still fails against a copy that leaves the supported-module list
unsorted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]