Skip to content

Commit

Permalink
Merge pull request #41 from bcliang/tox-testrunner
Browse files Browse the repository at this point in the history
Use tox as test runner
  • Loading branch information
bcliang authored Mar 9, 2021
2 parents b607e49 + de87707 commit 5145c47
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 13 deletions.
14 changes: 14 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[run]
branch = True
source =
gamry_parser

omit =
gamry_parser/__init__.py
gamry_praser/version.py

[report]
exclude_lines =
pragma: no cover
if __name__ == .__main__.
show_missing = True
12 changes: 7 additions & 5 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -23,6 +23,8 @@ jobs:
sudo /usr/share/locales/install-language-pack de_DE.UTF-8
sudo /usr/share/locales/install-language-pack en_US.UTF-8
sudo locale-gen --purge
pip install coverage
coverage run --source=gamry_parser/ setup.py test
coverage report -m
# pip install coverage
# coverage run --source=gamry_parser/ setup.py test
# coverage report -m
pip install tox coverage pytest tox-gh-actions
tox
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
-

### Changed
-
- [#40](https://github.com/bcliang/gamry-parser/pull/40) Change: GamryParser to_timestamp param #40
- [#41](https://github.com/bcliang/gamry-parser/pull/40) Use tox as test runner

### Added
-
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,14 @@ Tests extending `unittest.TestCase` may be found in `/tests/`.
Unit tests are triggered as part of every pull request, but users can run tests locally as well:

```bash
$ python setup.py test
$ coverage run --source=gamry_parser/ setup.py test
$ coverage report -m
$ tox
```

Alternatively, run `pytest` from your virtualenv (use the `-k` flag to filter tests)

```bash
$ pytest
$ pytest -v -k "test_getters"
```

### Code Guidelines
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
setuptools
coverage
pytest
19 changes: 19 additions & 0 deletions tests/cv_data_incompleteheader.dta
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
EXPLAIN
TAG CV
TITLE LABEL Cyclic Voltammetry Test &Identifier
DATE LABEL 3/6/2019 Date
TIME LABEL 16:35:22 Time
CHECKNOTES NOTES 1 &Notes...
test-notes-data
CHECKPSTAT PSTAT potentiostat-id Potentiostat
CHECKPOTEN POTEN 5.00000E-001 F Initial &E (V)
CHECKQUANT QUANT 1.2345E+000 &Scan Rate (mV/s)
CHECKIQUANT IQUANT 5 C&ycles (#)
CHECKSELECTOR SELECTOR 0 I/E Range &Mode
CHECKTOGGLE TOGGLE F Used for Stripping
CHECK2PARAM TWOPARAM T 3.00000E+002 5.00000E-001 Conditionin&g Time(s) E(V)
VLIMIT1 POTEN 1.00000E-001 F Scan Limit &1 (V)
VLIMIT2 POTEN 9.00000E-001 F Scan Limit &2 (V)
SCANRATE QUANT 1.23456E+000 &Scan Rate (mV/s)
CONDIT TWOPARAM F 3.00000E+002 4.00000E-001 Conditionin&g Time(s) E(V)
DELAY TWOPARAM F 3.00000E+002 1.00000E-001 Init. De&lay Time(s) Stab.(mV/s)
11 changes: 8 additions & 3 deletions tests/test_gamryparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ def test_read_header(self):
self.assertEqual(gp.header["CHECKSELECTOR"], 0)
self.assertFalse(gp.header["CHECKTOGGLE"])
self.assertTrue(isinstance(gp.header["CHECK2PARAM"], dict))
self.assertTrue(gp.header["CHECK2PARAM"]["enable"])
self.assertEqual(gp.header["CHECK2PARAM"]["start"], 300)
self.assertEqual(gp.header["CHECK2PARAM"]["finish"], 0.5)
self.assertTrue(gp.header["CHECK2PARAM"].get("enable", False))
self.assertEqual(gp.header["CHECK2PARAM"].get("start"), 300)
self.assertEqual(gp.header["CHECK2PARAM"].get("finish"), 0.5)

gp = parser.GamryParser(filename="tests/cv_data_incompleteheader.dta")
_, count = gp.read_header()
self.assertEqual(gp.header["DELAY"], dict(enable=False, start=300, finish=0.1))

def test_load(self):
locale.setlocale(locale.LC_ALL, "")
Expand All @@ -52,6 +56,7 @@ def test_load(self):
curve1 = gp.curves[0]
self.assertEqual(curve1["T"].iloc[0], 0.1)
self.assertEqual(curve1["T"].iloc[-1], 1.0)
self.assertEqual(curve1["Vf"].iloc[-1], 0.5)
self.assertEqual(curve1.index.dtype, np.int64)

curve5 = gp.curves[-1]
Expand Down
18 changes: 18 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tox]
envlist = py{36,37,38,39}

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39

[testenv]
deps =
pytest
coverage

commands = coverage erase
coverage run {envbindir}/pytest
coverage report --omit=*test*

0 comments on commit 5145c47

Please sign in to comment.