1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 15:57:34 +00:00
vorta/tests/conftest.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
998 B
Python
Raw Normal View History

import os
import sys
import pytest
2018-11-01 06:01:44 +00:00
import vorta
import vorta.application
import vorta.borg.jobs_manager
from peewee import SqliteDatabase
2018-11-01 06:01:44 +00:00
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')
2021-11-16 06:32:40 +00:00
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()