Merge pull request #424 from vkbo/pytest_action
GitHub action using pytest
This commit is contained in:
@@ -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
@@ -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,6 +1,6 @@
|
|||||||
# novelWriter
|
# novelWriter
|
||||||
|
|
||||||
[](https://travis-ci.com/vkbo/novelWriter)
|
[](https://github.com/vkbo/novelWriter/actions)
|
||||||
[](https://codecov.io/gh/vkbo/novelWriter)
|
[](https://codecov.io/gh/vkbo/novelWriter)
|
||||||
[](https://novelwriter.readthedocs.io/en/latest/?badge=latest)
|
[](https://novelwriter.readthedocs.io/en/latest/?badge=latest)
|
||||||
[](https://github.com/vkbo/novelWriter/actions)
|
[](https://github.com/vkbo/novelWriter/actions)
|
||||||
|
|||||||
+15
-9
@@ -297,6 +297,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
|
|||||||
projEdit.show()
|
projEdit.show()
|
||||||
qtbot.addWidget(projEdit)
|
qtbot.addWidget(projEdit)
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
projEdit.tabMain.editName.setText("")
|
projEdit.tabMain.editName.setText("")
|
||||||
for c in "Project Name":
|
for c in "Project Name":
|
||||||
qtbot.keyClick(projEdit.tabMain.editName, c, delay=keyDelay)
|
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)
|
qtbot.keyClick(projEdit.tabMain.editAuthors, c, delay=keyDelay)
|
||||||
|
|
||||||
# Test Status Tab
|
# Test Status Tab
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
projEdit._tabBox.setCurrentWidget(projEdit.tabStatus)
|
projEdit._tabBox.setCurrentWidget(projEdit.tabStatus)
|
||||||
projEdit.tabStatus.listBox.item(2).setSelected(True)
|
projEdit.tabStatus.listBox.item(2).setSelected(True)
|
||||||
qtbot.mouseClick(projEdit.tabStatus.delButton, Qt.LeftButton)
|
qtbot.mouseClick(projEdit.tabStatus.delButton, Qt.LeftButton)
|
||||||
@@ -321,6 +323,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
|
|||||||
qtbot.mouseClick(projEdit.tabStatus.saveButton, Qt.LeftButton)
|
qtbot.mouseClick(projEdit.tabStatus.saveButton, Qt.LeftButton)
|
||||||
|
|
||||||
# Auto-Replace Tab
|
# Auto-Replace Tab
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
projEdit._tabBox.setCurrentWidget(projEdit.tabReplace)
|
projEdit._tabBox.setCurrentWidget(projEdit.tabReplace)
|
||||||
|
|
||||||
qtbot.mouseClick(projEdit.tabReplace.addButton, Qt.LeftButton)
|
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.keyClick(projEdit.tabReplace.editValue, c, delay=keyDelay)
|
||||||
qtbot.mouseClick(projEdit.tabReplace.saveButton, Qt.LeftButton)
|
qtbot.mouseClick(projEdit.tabReplace.saveButton, Qt.LeftButton)
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
projEdit.tabReplace.listBox.clearSelection()
|
projEdit.tabReplace.listBox.clearSelection()
|
||||||
qtbot.mouseClick(projEdit.tabReplace.addButton, Qt.LeftButton)
|
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()
|
newIdx = -1
|
||||||
projEdit.tabReplace.listBox.topLevelItem(0).setSelected(True)
|
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.mouseClick(projEdit.tabReplace.delButton, Qt.LeftButton)
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
projEdit._doSave()
|
projEdit._doSave()
|
||||||
|
|
||||||
# Open again, and check project settings
|
# Open again, and check project settings
|
||||||
@@ -366,8 +372,8 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
|
|||||||
projFile = path.join(nwTempGUI, "nwProject.nwx")
|
projFile = path.join(nwTempGUI, "nwProject.nwx")
|
||||||
assert cmpFiles(projFile, path.join(nwRef, "gui", "2_nwProject.nwx"), [2, 8, 9, 10])
|
assert cmpFiles(projFile, path.join(nwRef, "gui", "2_nwProject.nwx"), [2, 8, 9, 10])
|
||||||
|
|
||||||
nwGUI.closeMain()
|
|
||||||
# qtbot.stopForInteraction()
|
# qtbot.stopForInteraction()
|
||||||
|
nwGUI.closeMain()
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp):
|
def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp):
|
||||||
|
|||||||
Reference in New Issue
Block a user