mirror of
https://github.com/borgbase/vorta
synced 2025-03-06 19:58:14 +00:00
More test fixes, avoid segfault when quitting (#877)
This commit is contained in:
parent
d701211037
commit
7949e80381
6 changed files with 44 additions and 18 deletions
19
.github/workflows/test.yml
vendored
19
.github/workflows/test.yml
vendored
|
@ -19,6 +19,19 @@ jobs:
|
|||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
- name: pip cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg', 'requirements.d/**') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
- name: Install system dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
|
@ -34,8 +47,10 @@ jobs:
|
|||
run: |
|
||||
pip install -e .
|
||||
pip install -r requirements.d/dev.txt
|
||||
|
||||
# - name: Setup tmate session
|
||||
# uses: mxschmitt/action-tmate@v1
|
||||
|
||||
- name: Test with pytest (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
|
@ -44,7 +59,8 @@ jobs:
|
|||
- name: Test with pytest (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
pytest --cov=vorta
|
||||
pytest
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
env:
|
||||
|
@ -53,6 +69,7 @@ jobs:
|
|||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
env_vars: OS, python
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
|
@ -75,7 +75,7 @@ class VortaApp(QtSingleApplication):
|
|||
self.backup_cancelled_event.connect(self.backup_cancelled_event_response)
|
||||
self.message_received_event.connect(self.message_received_event_response)
|
||||
self.backup_log_event.connect(self.react_to_log)
|
||||
self.aboutToQuit.connect(cleanup_db)
|
||||
self.aboutToQuit.connect(self.quit_app_action)
|
||||
self.set_borg_details_action()
|
||||
self.installEventFilter(self)
|
||||
|
||||
|
@ -101,6 +101,12 @@ class VortaApp(QtSingleApplication):
|
|||
self.tray.set_tray_icon()
|
||||
return False
|
||||
|
||||
def quit_app_action(self):
|
||||
del self.main_window
|
||||
self.scheduler.shutdown()
|
||||
self.backup_cancelled_event.emit()
|
||||
cleanup_db()
|
||||
|
||||
def create_backup_action(self, profile_id=None):
|
||||
if not profile_id:
|
||||
profile_id = self.main_window.current_profile.id
|
||||
|
|
|
@ -62,12 +62,13 @@ def get_directory_size(dir_path):
|
|||
if os.path.islink(file_path):
|
||||
continue
|
||||
|
||||
stat = os.stat(file_path)
|
||||
|
||||
# Visit each file once
|
||||
if stat.st_ino not in seen:
|
||||
seen.add(stat.st_ino)
|
||||
data_size += stat.st_size
|
||||
try:
|
||||
stat = os.stat(file_path)
|
||||
if stat.st_ino not in seen: # Visit each file only once
|
||||
seen.add(stat.st_ino)
|
||||
data_size += stat.st_size
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
|
||||
files_count = len(seen)
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ def qapp(tmpdir_factory):
|
|||
qapp = VortaApp([]) # Only init QApplication once to avoid segfaults while testing.
|
||||
|
||||
yield qapp
|
||||
qapp.quit()
|
||||
|
||||
|
||||
@pytest.fixture(scope='function', autouse=True)
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
import os
|
||||
import pytest
|
||||
import vorta.models
|
||||
import vorta.views
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5 import QtCore
|
||||
|
||||
|
||||
def test_add_folder(qapp, qtbot, tmpdir, monkeypatch, choose_file_dialog):
|
||||
def test_add_folder(qapp, qtbot, mocker, monkeypatch, choose_file_dialog):
|
||||
monkeypatch.setattr(
|
||||
vorta.views.source_tab, "choose_file_dialog", choose_file_dialog
|
||||
)
|
||||
|
@ -17,7 +13,12 @@ def test_add_folder(qapp, qtbot, tmpdir, monkeypatch, choose_file_dialog):
|
|||
tab.sourceAddFolder.click()
|
||||
qtbot.waitUntil(lambda: tab.sourceFilesWidget.rowCount() == 2, **pytest._wait_defaults)
|
||||
|
||||
# Test paste button
|
||||
QApplication.clipboard().setText(os.path.expanduser('~')) # Load clipboard
|
||||
qtbot.mouseClick(tab.paste, QtCore.Qt.LeftButton)
|
||||
assert tab.sourceFilesWidget.rowCount() == 3
|
||||
# Test paste button with mocked clipboard
|
||||
mock_clipboard = mocker.Mock()
|
||||
mock_clipboard.text.return_value = __file__
|
||||
mocker.patch.object(vorta.views.source_tab.QApplication, 'clipboard', return_value=mock_clipboard)
|
||||
tab.paste_text()
|
||||
qtbot.waitUntil(lambda: tab.sourceFilesWidget.rowCount() == 3, **pytest._wait_defaults)
|
||||
|
||||
# Wait for directory sizing to finish
|
||||
qtbot.waitUntil(lambda: len(qapp.main_window.sourceTab.updateThreads) == 0, **pytest._wait_defaults)
|
||||
|
|
|
@ -2,7 +2,7 @@ import uuid
|
|||
from vorta.keyring.abc import VortaKeyring
|
||||
|
||||
|
||||
def test_keyring(qapp):
|
||||
def test_keyring():
|
||||
UNICODE_PW = 'kjalsdfüadsfäadsfß'
|
||||
REPO = f'vorta-test-repo.{uuid.uuid4()}.com:repo' # Random repo URL
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue