2018-02-10 15:57:05 -05:00
|
|
|
import sys
|
2017-07-08 00:51:09 -04:00
|
|
|
import os
|
2020-10-14 23:17:08 -04:00
|
|
|
from datetime import datetime, timedelta
|
2017-07-08 00:51:09 -04:00
|
|
|
|
2022-10-23 08:09:56 -04:00
|
|
|
from PySide6 import QtTest
|
2020-10-14 23:17:08 -04:00
|
|
|
|
2021-04-30 14:38:23 -04:00
|
|
|
|
|
|
|
# Force tests to look for resources in the source code tree
|
|
|
|
sys.onionshare_dev_mode = True
|
|
|
|
|
|
|
|
# Let OnionShare know the tests are running, to avoid colliding with settings files
|
|
|
|
sys.onionshare_test_mode = True
|
|
|
|
|
2020-10-14 23:17:08 -04:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def qWait(t, qtapp):
|
|
|
|
end = datetime.now() + timedelta(milliseconds=t)
|
|
|
|
while datetime.now() < end:
|
|
|
|
qtapp.processEvents()
|
|
|
|
|
|
|
|
|
2022-10-23 08:09:56 -04:00
|
|
|
# Monkeypatch qWait, although PySide6 has it
|
2020-10-14 23:17:08 -04:00
|
|
|
# https://stackoverflow.com/questions/17960159/qwait-analogue-in-pyside
|
|
|
|
QtTest.QTest.qWait = qWait
|
|
|
|
|
|
|
|
# Allow importing onionshare_cli from the source tree
|
|
|
|
sys.path.insert(
|
|
|
|
0,
|
|
|
|
os.path.join(
|
|
|
|
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
|
|
|
"cli",
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2022-03-06 17:26:51 -05:00
|
|
|
# Create common and qtapp singletons
|
|
|
|
from onionshare_cli.common import Common
|
|
|
|
from onionshare import Application
|
2018-04-29 21:19:00 -04:00
|
|
|
|
2022-03-06 17:26:51 -05:00
|
|
|
common = Common(verbose=True)
|
|
|
|
qtapp = Application(common)
|
2019-10-13 00:01:25 -04:00
|
|
|
|
2022-03-06 17:26:51 -05:00
|
|
|
# Attach them to sys, so GuiBaseTest can retrieve them
|
|
|
|
sys.onionshare_common = common
|
|
|
|
sys.onionshare_qtapp = qtapp
|