Skip to content

Commit

Permalink
Merge pull request #24 from Zhaoli2042/main
Browse files Browse the repository at this point in the history
try github pytest workflow, currently checks input files in Examples/
  • Loading branch information
Zhaoli2042 authored Jun 18, 2024
2 parents 2f1c693 + 0245f06 commit 16331fd
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/python-test.yml
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
37 changes: 37 additions & 0 deletions Examples/test_examples.py
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')
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest>=6.0

0 comments on commit 16331fd

Please sign in to comment.