Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Add test targets for py files and notebooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
cfezequiel committed Oct 30, 2020
1 parent 7f3f480 commit 68d94e2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Please delete options that are not relevant.
- [ ] My code adheres to the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
- [ ] I ran `make pylint` and code is rated 10/10
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I ran `make test testnb` and all tests pass
- [ ] I ran `make test` and all tests pass
- [ ] I ran the tool and verified the change works
- [ ] I have adequately commented my code, particularly in hard-to-understand areas
- [ ] I have made relevant changes to the documentation, if needed
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/python-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ jobs:
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run Jupyter notebook tests
- name: Run all tests
run: |
export PYTHONPATH="$GITHUB_WORKSPACE"
make testnb
- name: Run Python tests
run: |
make test
- name: Lint with pylint
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ all: init testnb test pylint
init:
pip install -r requirements.txt

test:
test: test-nb test-py

test-py:
nosetests --with-coverage -v --cover-package=tfrecorder

testnb:
test-nb:
ls -1 samples/*.ipynb | grep -v '^.*Dataflow.ipynb' | xargs py.test --nbval-lax -p no:python

pylint:
pylint -j 0 tfrecorder

.PHONY: all init testnb test pylint
.PHONY: all init test pylint
6 changes: 3 additions & 3 deletions tfrecorder/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from tfrecorder import utils
from tfrecorder import test_utils
from tfrecorder import input_schema
from tfrecorder import dataset_loader as _dataset
from tfrecorder import dataset_loader


# pylint: disable=protected-access
Expand Down Expand Up @@ -69,7 +69,7 @@ def setUp(self):
self.data = data
self.dataset = tf.data.Dataset.from_tensor_slices(self.data)

@mock.patch.object(_dataset, 'load', autospec=True)
@mock.patch.object(dataset_loader, 'load', autospec=True)
def test_valid_records(self, mock_fn):
"""Tests valid case on reading multiple records."""

Expand Down Expand Up @@ -98,7 +98,7 @@ def test_valid_records(self, mock_fn):
expected_image_files = self.data['image_name']
self.assertCountEqual(actual_image_files, expected_image_files)

@mock.patch.object(_dataset, 'load', autospec=True)
@mock.patch.object(dataset_loader, 'load', autospec=True)
def test_no_data_for_split(self, mock_fn):
"""Check exception raised when data could not be loaded given `split`."""

Expand Down

0 comments on commit 68d94e2

Please sign in to comment.