Skip to content

Commit

Permalink
Run black.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyak committed Jan 16, 2021
1 parent 744cc7d commit 2873fd3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
25 changes: 15 additions & 10 deletions armi/utils/tests/test_gridGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2873fd3

Please sign in to comment.