From 2873fd3626f13ace6244ef5cf4eeee45b1cf7a7f Mon Sep 17 00:00:00 2001 From: Scott Yak Date: Sat, 16 Jan 2021 01:39:35 -0500 Subject: [PATCH] Run black. --- armi/utils/tests/test_gridGui.py | 25 +++++++++++++++---------- setup.py | 9 ++++++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/armi/utils/tests/test_gridGui.py b/armi/utils/tests/test_gridGui.py index cd2c794e49..652a15c89a 100644 --- a/armi/utils/tests/test_gridGui.py +++ b/armi/utils/tests/test_gridGui.py @@ -67,7 +67,12 @@ def _findPointInWindow( def _run_along_main_loop(func): - """Wraps each test case to allow simulated user interactions to run alongside the App's main loop.""" + """Wraps each test case to allow simulated user actions to run alongside the app's main loop. + + We use asyncio to block the test case from exiting the function before all the asserts have been called. + Otherwise, tests with failing asserts would still pass. + """ + def wrap_wrap_func(self): def wrap_func(fut: asyncio.Future): try: @@ -79,7 +84,10 @@ def wrap_func(fut: asyncio.Future): finally: for topLevelWindow in wx.GetTopLevelWindows(): if topLevelWindow: - if isinstance(topLevelWindow, wx.Dialog) and topLevelWindow.IsModal(): + if ( + isinstance(topLevelWindow, wx.Dialog) + and topLevelWindow.IsModal() + ): topLevelWindow.EndModal(0) wx.CallAfter(topLevelWindow.Destroy) else: @@ -98,7 +106,9 @@ def wrap_func(fut: asyncio.Future): class GridEditorTestCase(unittest.TestCase): def setUp(self): self.app = wx.App() - self.frame = wx.Frame(None, wx.ID_ANY, title="Grid Blueprints UI", pos=(0, 0), size=(1000, 1000)) + self.frame = wx.Frame( + None, wx.ID_ANY, title="Grid Blueprints UI", pos=(0, 0), size=(1000, 1000) + ) self.gui = gridEditor.GridBlueprintControl(self.frame) self.frame.Show() self.inputSimulator = wx.UIActionSimulator() @@ -109,7 +119,6 @@ def run(self, result=None): class Test(GridEditorTestCase): - def test_setNumRings(self): # Set the number of rings to 1 self.inputSimulator.MouseMove( @@ -124,9 +133,7 @@ def test_setNumRings(self): _wait(num_ticks=5) # Select (i, j) specifier - self.inputSimulator.MouseMove( - _findPointInWindow(self.gui.controls.labelMode) - ) + self.inputSimulator.MouseMove(_findPointInWindow(self.gui.controls.labelMode)) _wait(num_ticks=5) self.inputSimulator.MouseDown() _wait(num_ticks=1) @@ -142,9 +149,7 @@ def test_setNumRings(self): _wait(num_ticks=5) # Click the Apply button - self.inputSimulator.MouseMove( - _findPointInWindow(self.gui.controls.ringApply) - ) + self.inputSimulator.MouseMove(_findPointInWindow(self.gui.controls.ringApply)) _wait(num_ticks=5) self.inputSimulator.MouseDown() _wait(num_ticks=1) diff --git a/setup.py b/setup.py index 8a73bbaed2..8bff98e94d 100644 --- a/setup.py +++ b/setup.py @@ -99,7 +99,14 @@ def collectExtraFiles(): "sphinx-gallery", ], }, - tests_require=["nbconvert", "jupyter_client", "ipykernel", "wxpython", "pytest-xvfb", "screeninfo"], + tests_require=[ + "nbconvert", + "jupyter_client", + "ipykernel", + "wxpython", + "pytest-xvfb", + "screeninfo", + ], classifiers=[ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research",