-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from Zhaoli2042/main
try github pytest workflow, currently checks input files in Examples/
- Loading branch information
Showing
3 changed files
with
62 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,24 @@ | ||
name: Python application test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' # Specify the Python version | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Run pytest | ||
run: | | ||
cd Examples/; pytest # Assuming your tests are in the 'tests' directory |
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,37 @@ | ||
# test_calculator.py | ||
import pytest, os | ||
#from calculator import add | ||
|
||
import os | ||
|
||
def truthy(value): | ||
return bool(value) | ||
def falsy(value): | ||
return not bool(value) | ||
|
||
def check_files(directory, filename): | ||
# Get all items in the directory | ||
items = os.listdir(directory) | ||
|
||
# Loop through each item | ||
for item in items: | ||
if item.startswith('.') or item.startswith('__'): | ||
continue | ||
item_path = os.path.join(directory, item) | ||
|
||
# Check if the item is a directory | ||
if os.path.isdir(item_path): | ||
# Construct the path to the potential simulation.input file | ||
simulation_input_path = os.path.join(item_path, filename) | ||
|
||
# Check if simulation.input exists in this directory | ||
if not os.path.exists(simulation_input_path): | ||
print(f"Could not find {filename} in {item_path}\n") | ||
return False | ||
return True | ||
|
||
def test_file(): | ||
current_directory = os.getcwd() + '/' | ||
assert check_files(current_directory, 'simulation.input') | ||
assert not check_files(current_directory, 'force_field.def') | ||
#assert not check_files(current_directory, 'asdasd.def') |
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 @@ | ||
pytest>=6.0 |