diff --git a/tests/test_graphical_about_app.py b/tests/test_graphical_about_app.py index 409c2024..231b22e5 100644 --- a/tests/test_graphical_about_app.py +++ b/tests/test_graphical_about_app.py @@ -171,7 +171,3 @@ class TestGraphicalAboutApp(unittest.TestCase): print("=== OS version test completed successfully ===") -if __name__ == "__main__": - # Note: This file is executed by unittest.sh which handles unittest.main() - # But we include it here for completeness - unittest.main() diff --git a/tests/test_graphical_animation_deleted_widget.py b/tests/test_graphical_animation_deleted_widget.py index b64ca236..724c2653 100644 --- a/tests/test_graphical_animation_deleted_widget.py +++ b/tests/test_graphical_animation_deleted_widget.py @@ -214,5 +214,3 @@ class TestAnimationDeletedWidget(unittest.TestCase): print("=== Multiple animations test PASSED ===") -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_graphical_custom_keyboard.py b/tests/test_graphical_custom_keyboard.py index 77ae61a0..5f360a2d 100644 --- a/tests/test_graphical_custom_keyboard.py +++ b/tests/test_graphical_custom_keyboard.py @@ -316,5 +316,3 @@ class TestGraphicalMposKeyboard(unittest.TestCase): print("=== Comparison test PASSED ===") -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_graphical_custom_keyboard_basic.py b/tests/test_graphical_custom_keyboard_basic.py index 34bf42c3..90a870b7 100644 --- a/tests/test_graphical_custom_keyboard_basic.py +++ b/tests/test_graphical_custom_keyboard_basic.py @@ -188,5 +188,3 @@ class TestMposKeyboard(unittest.TestCase): print("API compatibility verified") -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_graphical_keyboard_animation.py b/tests/test_graphical_keyboard_animation.py index 0c171ee9..548cfe07 100644 --- a/tests/test_graphical_keyboard_animation.py +++ b/tests/test_graphical_keyboard_animation.py @@ -185,5 +185,3 @@ class TestKeyboardAnimation(unittest.TestCase): print("=== Position methods test PASSED ===") -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_graphical_keyboard_method_forwarding.py b/tests/test_graphical_keyboard_method_forwarding.py index ebaafa53..e96b3d63 100644 --- a/tests/test_graphical_keyboard_method_forwarding.py +++ b/tests/test_graphical_keyboard_method_forwarding.py @@ -141,5 +141,3 @@ class TestMethodForwarding(unittest.TestCase): print("Method forwarding preserves behavior correctly!") -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_graphical_keyboard_styling.py b/tests/test_graphical_keyboard_styling.py index 8bde4ab2..39dae61f 100644 --- a/tests/test_graphical_keyboard_styling.py +++ b/tests/test_graphical_keyboard_styling.py @@ -373,7 +373,3 @@ class TestKeyboardStyling(unittest.TestCase): print("=== Pure white test PASSED ===") -if __name__ == "__main__": - # Note: This file is executed by unittest.sh which handles unittest.main() - # But we include it here for completeness - unittest.main() diff --git a/tests/test_graphical_start_app.py b/tests/test_graphical_start_app.py index 8d7c088e..f2423ba4 100644 --- a/tests/test_graphical_start_app.py +++ b/tests/test_graphical_start_app.py @@ -67,5 +67,3 @@ class TestStartApp(unittest.TestCase): print("Launcher restart successful") -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_intent.py b/tests/test_intent.py index ecb8e5ec..34ef5de5 100644 --- a/tests/test_intent.py +++ b/tests/test_intent.py @@ -302,5 +302,3 @@ class TestIntent(unittest.TestCase): self.assertTrue(intent.extras["data"]["config"]["retry"]) -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_osupdate.py b/tests/test_osupdate.py index 17df0a3d..e8b36c8b 100644 --- a/tests/test_osupdate.py +++ b/tests/test_osupdate.py @@ -564,5 +564,3 @@ class TestUpdateDownloader(unittest.TestCase): self.assertEqual(result['bytes_written'], 8192) -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_osupdate_graphical.py b/tests/test_osupdate_graphical.py index 9b2147a6..8cfee17c 100644 --- a/tests/test_osupdate_graphical.py +++ b/tests/test_osupdate_graphical.py @@ -325,5 +325,3 @@ class TestOSUpdateGraphicalScreenshots(unittest.TestCase): capture_screenshot(screenshot_path) -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_shared_preferences.py b/tests/test_shared_preferences.py index 954953d9..04c47e82 100644 --- a/tests/test_shared_preferences.py +++ b/tests/test_shared_preferences.py @@ -476,5 +476,3 @@ class TestSharedPreferences(unittest.TestCase): self.assertEqual(loaded["settings"]["limits"][2], 30) -if __name__ == '__main__': - unittest.main() diff --git a/tests/unittest.sh b/tests/unittest.sh index 42ea9583..8028ac7f 100755 --- a/tests/unittest.sh +++ b/tests/unittest.sh @@ -5,6 +5,7 @@ mydir=$(dirname "$mydir") testdir="$mydir" scriptdir=$(readlink -f "$mydir"/../scripts/) fs="$mydir"/../internal_filesystem/ +mpremote="$mydir"/../lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py # Parse arguments ondevice="" @@ -22,6 +23,11 @@ while [ $# -gt 0 ]; do shift done +if [ ! -z "$ondevice" ]; then + echo "Hack: reset the device to make sure no previous UnitTest classes have been registered..." + "$mpremote" reset + sleep 15 +fi # print os and set binary os_name=$(uname -s) @@ -80,7 +86,7 @@ result = unittest.main() ; sys.exit(0 if result.wasSuccessful() else 1) " echo "$test logging to $testlog" if [ $is_graphical -eq 1 ]; then # Graphical test: system already initialized, just add test paths - mpremote.py exec "import sys ; sys.path.append('lib') ; sys.path.append('tests') + "$mpremote" exec "import sys ; sys.path.append('lib') ; sys.path.append('tests') $(cat $file) result = unittest.main() if result.wasSuccessful(): @@ -90,7 +96,7 @@ else: " | tee "$testlog" else # Regular test: no boot files - mpremote.py exec "import sys ; sys.path.append('lib') + "$mpremote" exec "import sys ; sys.path.append('lib') $(cat $file) result = unittest.main() if result.wasSuccessful(): @@ -99,7 +105,7 @@ else: print('TEST WAS A FAILURE') " | tee "$testlog" fi - grep "TEST WAS A SUCCESS" "$testlog" + grep -q "TEST WAS A SUCCESS" "$testlog" result=$? fi popd