-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for verifying imports (#24)
- added a script that runs unit tests to see if library imports of fmperf are working - also added a github action workflow to automate the testing upon push and pull request
- Loading branch information
Showing
3 changed files
with
67 additions
and
1 deletion.
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,27 @@ | ||
name: Pytest | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -e . | ||
pip install -r requirements.txt | ||
- name: Run tests | ||
run: | | ||
pytest fmperf/tests/ |
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
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,39 @@ | ||
import unittest | ||
import logging | ||
|
||
|
||
# Configure logging | ||
logging.basicConfig( | ||
filename="test_logs.log", | ||
level=logging.DEBUG, | ||
format="%(asctime)s %(levelname)s:%(message)s", | ||
filemode="w", | ||
) | ||
logging.debug("Logging configured successfully") | ||
|
||
|
||
# Test class to check if the imports are working for the files in the examples folder | ||
class TestImports(unittest.TestCase): | ||
def setUp(self): | ||
# Setup code goes here | ||
logging.info("Running a test case.") | ||
|
||
def tearDown(self): | ||
# Teardown code can go here, if we needed to clean up after tests | ||
pass | ||
|
||
def test_fmperf_import(self): | ||
"""Test if fmperf import works correctly.""" | ||
try: | ||
import fmperf | ||
|
||
self.assertIsNotNone(fmperf) | ||
logging.info("test_fmperf_import passed.") | ||
except Exception as e: | ||
logging.error(f"test_fmperf_import failed: {e}") | ||
raise | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() | ||
logging.getLogger().handlers[0].flush() |