1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 07:43:09 +00:00
vorta/tests/conftest.py

37 lines
999 B
Python

import os
import sys
import pytest
from peewee import SqliteDatabase
import vorta
import vorta.application
import vorta.borg.jobs_manager
def pytest_configure(config):
sys._called_from_test = True
pytest._wait_defaults = {'timeout': 20000}
os.environ['LANG'] = 'en' # Ensure we test an English UI
@pytest.fixture(scope='session')
def qapp(tmpdir_factory):
# DB is required to init QApplication. New DB used for every test.
tmp_db = tmpdir_factory.mktemp('Vorta').join('settings.sqlite')
mock_db = SqliteDatabase(str(tmp_db))
vorta.store.connection.init_db(mock_db)
# Needs to be disabled before calling VortaApp()
if sys.platform == 'darwin':
cfg = vorta.store.models.SettingsModel.get(key='check_full_disk_access')
cfg.value = False
cfg.save()
from vorta.application import VortaApp
qapp = VortaApp([]) # Only init QApplication once to avoid segfaults while testing.
yield qapp
mock_db.close()
qapp.quit()