Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds #478 changes from dev-sci #479

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")