From 733111150c1600e3235d728189532c84a93b5067 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 22 Apr 2026 17:51:47 -0700 Subject: [PATCH 1/4] Remove unused testresources import and related load_tests function from unittestadapter --- build/test-requirements.txt | 1 - .../.data/test_scenarios/tests/__init__.py | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/build/test-requirements.txt b/build/test-requirements.txt index 6d64ff72ac7f..2521251b0c71 100644 --- a/build/test-requirements.txt +++ b/build/test-requirements.txt @@ -12,7 +12,6 @@ flask fastapi uvicorn django -testresources testscenarios # Integrated TensorBoard tests diff --git a/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py b/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py index 6b8fbbc579ab..b9d4a32ebdce 100644 --- a/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py +++ b/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py @@ -1,15 +1,3 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import os - -import testresources -from testscenarios import generate_scenarios - -def load_tests(loader, tests, pattern): - this_dir = os.path.dirname(__file__) - mytests = loader.discover(start_dir=this_dir, pattern=pattern) - result = testresources.OptimisingTestSuite() - result.addTests(generate_scenarios(mytests)) - result.addTests(generate_scenarios(tests)) - return result From 3410532519e83e17820cd9b134d8fefce570bf0a Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Thu, 23 Apr 2026 08:38:33 -0700 Subject: [PATCH 2/4] fixing --- build/test-requirements.txt | 1 + .../unittestadapter/.data/test_scenarios/tests/test_scene.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build/test-requirements.txt b/build/test-requirements.txt index 2521251b0c71..ff9afdfc8a2e 100644 --- a/build/test-requirements.txt +++ b/build/test-requirements.txt @@ -13,6 +13,7 @@ fastapi uvicorn django testscenarios +testtools # Integrated TensorBoard tests tensorboard diff --git a/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.py b/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.py index 1f66cbde4ef7..b89a757ab6b4 100644 --- a/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.py +++ b/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.py @@ -3,11 +3,12 @@ from testscenarios import TestWithScenarios + class TestMathOperations(TestWithScenarios): scenarios = [ ('add', {'test_id': 'test_add', 'a': 5, 'b': 3, 'expected': 8}), ('subtract', {'test_id': 'test_subtract', 'a': 5, 'b': 3, 'expected': 2}), - ('multiply', {'test_id': 'test_multiply', 'a': 5, 'b': 3, 'expected': 15}) + ('multiply', {'test_id': 'test_multiply', 'a': 5, 'b': 3, 'expected': 15}), ] a: int = 0 b: int = 0 From f4e9f5b37146cb7c9b91f6703820577899e6e668 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Thu, 23 Apr 2026 08:42:55 -0700 Subject: [PATCH 3/4] update --- .../.data/test_scenarios/tests/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py b/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py index b9d4a32ebdce..f1b61cb0fd01 100644 --- a/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py +++ b/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py @@ -1,3 +1,17 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +from testscenarios import generate_scenarios + + +def load_tests(loader, tests, pattern): # noqa: ARG001 + # Pre-expand TestWithScenarios scenarios at load time so individual + # scenario-multiplied test IDs (e.g. ``test_operations(add)``) can be + # resolved by ``unittest.TestLoader.loadTestsFromName``. Without this, + # ``TestWithScenarios`` only multiplies scenarios at ``run()`` time and + # loading a specific scenario by name raises ``AttributeError``. + import unittest + + result = unittest.TestSuite() + result.addTests(generate_scenarios(tests)) + return result From 4319307604d18f79c26a36ceb03f1690e63c1a52 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Thu, 23 Apr 2026 08:46:34 -0700 Subject: [PATCH 4/4] move loader to fix issue Co-authored-by: Copilot --- .../.data/test_scenarios/tests/__init__.py | 15 --------------- .../.data/test_scenarios/tests/test_scene.py | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py b/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py index f1b61cb0fd01..5b7f7a925cc0 100644 --- a/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py +++ b/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.py @@ -1,17 +1,2 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. - -from testscenarios import generate_scenarios - - -def load_tests(loader, tests, pattern): # noqa: ARG001 - # Pre-expand TestWithScenarios scenarios at load time so individual - # scenario-multiplied test IDs (e.g. ``test_operations(add)``) can be - # resolved by ``unittest.TestLoader.loadTestsFromName``. Without this, - # ``TestWithScenarios`` only multiplies scenarios at ``run()`` time and - # loading a specific scenario by name raises ``AttributeError``. - import unittest - - result = unittest.TestSuite() - result.addTests(generate_scenarios(tests)) - return result diff --git a/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.py b/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.py index b89a757ab6b4..35c1c7002319 100644 --- a/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.py +++ b/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.py @@ -1,7 +1,20 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from testscenarios import TestWithScenarios +import unittest + +from testscenarios import TestWithScenarios, generate_scenarios + + +def load_tests(loader, standard_tests, pattern): # noqa: ARG001 + # Pre-expand ``TestWithScenarios`` scenarios at load time so individual + # scenario-multiplied test IDs (e.g. ``test_operations(add)``) can be + # resolved by ``unittest.TestLoader.loadTestsFromName``. Without this, + # ``TestWithScenarios`` only multiplies scenarios at ``run()`` time and + # loading a specific scenario by name raises ``AttributeError``. + result = unittest.TestSuite() + result.addTests(generate_scenarios(standard_tests)) + return result class TestMathOperations(TestWithScenarios):