Skip to content

Commit fba0a8c

Browse files
Fix exceptions in unit tests
1 parent 109c110 commit fba0a8c

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

utest/application/test_app_main.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pytest
1717
from pytest import MonkeyPatch
1818
import builtins
19+
import wx
1920

2021
real_import = builtins.__import__
2122

@@ -232,15 +233,21 @@ def test_replace_std_for_win(self):
232233

233234
class TestMisc(unittest.TestCase):
234235

236+
def setUp(self):
237+
from robotide.application import RIDE
238+
self.main_app = RIDE()
239+
self.settings = self.main_app.settings
240+
self.frame = self.main_app.frame
241+
self.main_app.SetExitOnFrameDelete(True)
242+
243+
235244
def tearDown(self):
236245
builtins.__import__ = real_import
246+
self.main_app.Destroy()
247+
self.main_app = None
237248

238249
def test_get_code(self):
239-
import wx
240-
from robotide.application import RIDE
241-
242-
main_app = RIDE()
243-
code = main_app._get_language_code()
250+
code = self.main_app._get_language_code()
244251
assert code in (175, wx.LANGUAGE_ENGLISH_WORLD, wx.LANGUAGE_PORTUGUESE)
245252

246253

utest/zulu_misc/test_get_language_code.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import unittest
15+
import wx
1516

1617
class TestMisc(unittest.TestCase):
1718

18-
def test_get_code(self):
19-
import wx
19+
def setUp(self):
2020
from robotide.application import RIDE
21+
self.main_app = RIDE()
22+
self.settings = self.main_app.settings
23+
self.frame = self.main_app.frame
24+
self.main_app.SetExitOnFrameDelete(True)
25+
2126

22-
main_app = RIDE()
23-
code = main_app._get_language_code()
27+
def tearDown(self):
28+
self.main_app.Destroy()
29+
self.main_app = None
30+
31+
def test_get_code(self):
32+
code = self.main_app._get_language_code()
2433
assert code in (wx.LANGUAGE_ENGLISH, wx.LANGUAGE_ENGLISH_WORLD, wx.LANGUAGE_PORTUGUESE)
2534
# Uncomment next lines if you want to see the app
2635
# wx.CallLater(8000, main_app.ExitMainLoop)

0 commit comments

Comments
 (0)