Skip to content

Commit

Permalink
Adds #478 changes from dev-sci (#479)
Browse files Browse the repository at this point in the history
 but have a question about the location of the .toml file.
  • Loading branch information
MatthewPyle-NOAA authored Sep 19, 2024
1 parent 53dfccf commit 93fac0e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pytest_flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov coverage numpy netCDF4
pip install flake8 pytest pytest-cov coverage numpy netCDF4 jinja2
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors
flake8 . --count --select=E9 --show-source --statistics
flake8 . --count --select=E9,F63,F7 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
#flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: pytest
run: |
pytest
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.pytest.ini_options]
addopts = "-ra --cov"
testpaths = ['tests']
pythonpath = ['.']

25 changes: 25 additions & 0 deletions tests/ush/python_utils/test_misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

from ush.python_utils.misc import *

class TestMisc:
"""Test the misc.py functions."""

def test_uc(self):
"""Test the uppercase() function."""
assert uppercase('s') == 'S'

def test_lc(self):
"""Test the lowercase() function."""
assert lowercase('S') == 's'

def test_find_pattern_in_str(self):
"""Test the find_pattern_in_str() function."""
assert not find_pattern_in_str('.', 's')

def test_find_pattern_in_fike(self):
"""Test the find_pattern_in_file() function."""
f = open("test_misc.txt", "w")
f.write("Hello World from " + f.name)
f.close()
assert not find_pattern_in_file('H', "test_misc.txt")

0 comments on commit 93fac0e

Please sign in to comment.