-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Unit Testing Workflow using PyTest (#400)
* Add PyTest CI workflow * Add initial Unit Test * Testing-CI: Cache Python Pip dependencies * Testing-CI: Add Qt dependencies
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Test using Pytest | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
tests: | ||
name: "Run PyTest" | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "${{ matrix.python-version }}" | ||
cache: "pip" | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt install -y libegl1 libxkbcommon0 | ||
pip install pytest pytest-md pytest-emoji | ||
- name: Install ProtonUp-Qt | ||
run: pip install -e . | ||
|
||
- name: Run pytest | ||
uses: pavelzw/pytest-action@v2 | ||
env: | ||
QT_QPA_PLATFORM: "offscreen" | ||
with: | ||
verbose: true | ||
emoji: true | ||
job-summary: true | ||
custom-arguments: '-q' | ||
click-to-expand: true | ||
report-title: 'ProtonUp-Qt Test Report' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from pupgui2.util import * | ||
|
||
from pupgui2.datastructures import SteamApp, LutrisGame, HeroicGame | ||
|
||
|
||
def test_get_random_game_name(): | ||
""" test whether get_random_game_name returns a valid game name """ | ||
names = ["game", "A super cool game", "A game with a very long name that is very long", "0123456789"] | ||
|
||
steam_app = [SteamApp() for _ in range(len(names))] | ||
lutris_game = [LutrisGame() for _ in range(len(names))] | ||
heroic_game = [HeroicGame() for _ in range(len(names))] | ||
|
||
for i, name in enumerate(names): | ||
steam_app[i].game_name = name | ||
lutris_game[i].name = name | ||
heroic_game[i].title = name | ||
|
||
for i in range(10): | ||
assert get_random_game_name(steam_app) in names | ||
assert get_random_game_name(lutris_game) in names | ||
assert get_random_game_name(heroic_game) in names |