Merge pull request #424 from vkbo/pytest_action

GitHub action using pytest
This commit is contained in:
Veronica K. Berglyd Olsen
2020-08-20 21:28:05 +02:00
committed by GitHub
4 changed files with 74 additions and 67 deletions
+58
View File
@@ -0,0 +1,58 @@
name: PyTest
on:
pull_request:
branches: [ main, dev ]
jobs:
pyTestCov:
runs-on: ubuntu-latest
steps:
- name: Python Setup
uses: actions/setup-python@v1
with:
python-version: 3.8
architecture: x64
- name: Install Packages
run: sudo apt install xvfb libenchant-dev qt5-default
- name: Checkout Source
uses: actions/checkout@v2
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install PyVirtualDisplay
pip install pytest-cov
pip install pytest-xvfb
pip install pytest-qt
pip install codecov
- name: Run Tests
run: xvfb-run pytest -v --cov=nw
- name: Upload to Codecov
uses: codecov/codecov-action@v1
pyTest:
needs: pyTestCov
strategy:
matrix:
python-version: [3.6, 3.7]
runs-on: ubuntu-latest
steps:
- name: Python Setup
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Packages
run: sudo apt install xvfb libenchant-dev qt5-default
- name: Checkout Source
uses: actions/checkout@v2
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install PyVirtualDisplay
pip install pytest-xvfb
pip install pytest-qt
- name: Run Tests
run: xvfb-run pytest -v
-57
View File
@@ -1,57 +0,0 @@
os: linux
dist: focal
services:
- xvfb
language: python
cache:
- bundler
addons:
apt:
packages:
- libenchant-dev
- python3-pyqt5
- python3-pyqt5.qtsvg
- python3-lxml
install:
# - pip install --upgrade pip
- pip install -r requirements.txt
- pip install PyVirtualDisplay
- pip install pytest-cov
- pip install pytest-xvfb
- pip install pytest-qt
- pip install codecov
stages:
- name: Main
- name: Supported
# - name: Future
# if: branch = main
jobs:
include:
- stage: Main
python: 3.8
script:
- python -m pytest --cov=nw -v
after_success:
- codecov
after_failure:
- cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes
- stage: Supported
python: 3.6
script:
- python -m pytest -v
- python: 3.7
script:
- python -m pytest -v
# - stage:
# - Future
# python:
# - 3.9-dev
# script:
# - python -m pytest -v
+1 -1
View File
@@ -1,6 +1,6 @@
# novelWriter
[![Build Status](https://travis-ci.com/vkbo/novelWriter.svg?branch=main)](https://travis-ci.com/vkbo/novelWriter)
[![PyTest + Coverage](https://github.com/vkbo/novelWriter/workflows/PyTest%20+%20Coverage/badge.svg?branch=main)](https://github.com/vkbo/novelWriter/actions)
[![codecov](https://codecov.io/gh/vkbo/novelWriter/branch/main/graph/badge.svg)](https://codecov.io/gh/vkbo/novelWriter)
[![Documentation Status](https://readthedocs.org/projects/novelwriter/badge/?version=latest)](https://novelwriter.readthedocs.io/en/latest/?badge=latest)
[![Flake8 Checks](https://github.com/vkbo/novelWriter/workflows/Flake8%20Checks/badge.svg)](https://github.com/vkbo/novelWriter/actions)
+15 -9
View File
@@ -297,6 +297,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
projEdit.show()
qtbot.addWidget(projEdit)
qtbot.wait(stepDelay)
projEdit.tabMain.editName.setText("")
for c in "Project Name":
qtbot.keyClick(projEdit.tabMain.editName, c, delay=keyDelay)
@@ -309,6 +310,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
qtbot.keyClick(projEdit.tabMain.editAuthors, c, delay=keyDelay)
# Test Status Tab
qtbot.wait(stepDelay)
projEdit._tabBox.setCurrentWidget(projEdit.tabStatus)
projEdit.tabStatus.listBox.item(2).setSelected(True)
qtbot.mouseClick(projEdit.tabStatus.delButton, Qt.LeftButton)
@@ -321,6 +323,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
qtbot.mouseClick(projEdit.tabStatus.saveButton, Qt.LeftButton)
# Auto-Replace Tab
qtbot.wait(stepDelay)
projEdit._tabBox.setCurrentWidget(projEdit.tabReplace)
qtbot.mouseClick(projEdit.tabReplace.addButton, Qt.LeftButton)
@@ -331,19 +334,22 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
qtbot.keyClick(projEdit.tabReplace.editValue, c, delay=keyDelay)
qtbot.mouseClick(projEdit.tabReplace.saveButton, Qt.LeftButton)
qtbot.wait(stepDelay)
projEdit.tabReplace.listBox.clearSelection()
qtbot.mouseClick(projEdit.tabReplace.addButton, Qt.LeftButton)
projEdit.tabReplace.listBox.topLevelItem(0).setSelected(True)
for c in "Delete":
qtbot.keyClick(projEdit.tabReplace.editKey, c, delay=keyDelay)
for c in "This Stuff":
qtbot.keyClick(projEdit.tabReplace.editValue, c, delay=keyDelay)
qtbot.mouseClick(projEdit.tabReplace.saveButton, Qt.LeftButton)
projEdit.tabReplace.listBox.clearSelection()
projEdit.tabReplace.listBox.topLevelItem(0).setSelected(True)
newIdx = -1
for i in range(projEdit.tabReplace.listBox.topLevelItemCount()):
if projEdit.tabReplace.listBox.topLevelItem(i).text(0) == "<keyword2>":
newIdx = i
break
assert newIdx >= 0
newItem = projEdit.tabReplace.listBox.topLevelItem(newIdx)
projEdit.tabReplace.listBox.setCurrentItem(newItem)
qtbot.mouseClick(projEdit.tabReplace.delButton, Qt.LeftButton)
qtbot.wait(stepDelay)
projEdit._doSave()
# Open again, and check project settings
@@ -366,8 +372,8 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
projFile = path.join(nwTempGUI, "nwProject.nwx")
assert cmpFiles(projFile, path.join(nwRef, "gui", "2_nwProject.nwx"), [2, 8, 9, 10])
nwGUI.closeMain()
# qtbot.stopForInteraction()
nwGUI.closeMain()
@pytest.mark.gui
def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp):