Okay, I've been doing some tests, so I need to check the result every time I run a method. Because the test doesn't work properly.
I've made an example that works fine(not a test, but same behavior). In my test the result doesn't change, while in the example it changes.
EXAMPLE
def thread():
global result
import time
time.sleep(0.5)
result = 5/2
Gtk.main_quit()
import threading
from gi.repository import Gtk
result = None
t = threading.Thread(target=thread, args=())
t.start()
Gtk.main()
print result
OUTPUT: 2
TEST
def testSi_Button_clicked(self):
def thread(button=self.builder.get_object('Si_Button')):
import time
global result
time.sleep(0.5)
result = self.esci.Si_Button_clicked(button)
print 'result ' + str(result)
#Gtk.main_quit()
import threading
self.current_window = 'Home_Window' #DO NOT TRY WITH 'Azioni_Window'
result = None
t = threading.Thread(target=thread, args=())
t.start()
Gtk.main()
print 'assert'
print 'result ' + str(result)
self.assertIsNotNone(result)
OUTPUT:
Home_Window
return true
result True
assert
result None
F
======================================================================
FAIL: testSi_Button_clicked (testC_Esci.tstEsci)
----------------------------------------------------------------------
Traceback (most recent call last):
File "testC_Esci.py", line 78, in testSi_Button_clicked
self.assertIsNotNone(result)
AssertionError: unexpectedly None