Skip to content

Commit 5145c47

Browse files
authored
Merge pull request #41 from bcliang/tox-testrunner
Use tox as test runner
2 parents b607e49 + de87707 commit 5145c47

File tree

8 files changed

+77
-13
lines changed

8 files changed

+77
-13
lines changed

.coveragerc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[run]
2+
branch = True
3+
source =
4+
gamry_parser
5+
6+
omit =
7+
gamry_parser/__init__.py
8+
gamry_praser/version.py
9+
10+
[report]
11+
exclude_lines =
12+
pragma: no cover
13+
if __name__ == .__main__.
14+
show_missing = True

.github/workflows/unittest.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
9+
python-version: [3.6, 3.7, 3.8, 3.9]
1010

1111
steps:
1212
- uses: actions/checkout@v2
1313
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v1
14+
uses: actions/setup-python@v2
1515
with:
1616
python-version: ${{ matrix.python-version }}
1717
- name: Install dependencies
@@ -23,6 +23,8 @@ jobs:
2323
sudo /usr/share/locales/install-language-pack de_DE.UTF-8
2424
sudo /usr/share/locales/install-language-pack en_US.UTF-8
2525
sudo locale-gen --purge
26-
pip install coverage
27-
coverage run --source=gamry_parser/ setup.py test
28-
coverage report -m
26+
# pip install coverage
27+
# coverage run --source=gamry_parser/ setup.py test
28+
# coverage report -m
29+
pip install tox coverage pytest tox-gh-actions
30+
tox

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
-
99

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

1314
### Added
1415
-

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,14 @@ Tests extending `unittest.TestCase` may be found in `/tests/`.
124124
Unit tests are triggered as part of every pull request, but users can run tests locally as well:
125125

126126
```bash
127-
$ python setup.py test
128-
$ coverage run --source=gamry_parser/ setup.py test
129-
$ coverage report -m
127+
$ tox
128+
```
129+
130+
Alternatively, run `pytest` from your virtualenv (use the `-k` flag to filter tests)
131+
132+
```bash
133+
$ pytest
134+
$ pytest -v -k "test_getters"
130135
```
131136

132137
### Code Guidelines

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
setuptools
2-
coverage
2+
pytest

tests/cv_data_incompleteheader.dta

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
EXPLAIN
2+
TAG CV
3+
TITLE LABEL Cyclic Voltammetry Test &Identifier
4+
DATE LABEL 3/6/2019 Date
5+
TIME LABEL 16:35:22 Time
6+
CHECKNOTES NOTES 1 &Notes...
7+
test-notes-data
8+
CHECKPSTAT PSTAT potentiostat-id Potentiostat
9+
CHECKPOTEN POTEN 5.00000E-001 F Initial &E (V)
10+
CHECKQUANT QUANT 1.2345E+000 &Scan Rate (mV/s)
11+
CHECKIQUANT IQUANT 5 C&ycles (#)
12+
CHECKSELECTOR SELECTOR 0 I/E Range &Mode
13+
CHECKTOGGLE TOGGLE F Used for Stripping
14+
CHECK2PARAM TWOPARAM T 3.00000E+002 5.00000E-001 Conditionin&g Time(s) E(V)
15+
VLIMIT1 POTEN 1.00000E-001 F Scan Limit &1 (V)
16+
VLIMIT2 POTEN 9.00000E-001 F Scan Limit &2 (V)
17+
SCANRATE QUANT 1.23456E+000 &Scan Rate (mV/s)
18+
CONDIT TWOPARAM F 3.00000E+002 4.00000E-001 Conditionin&g Time(s) E(V)
19+
DELAY TWOPARAM F 3.00000E+002 1.00000E-001 Init. De&lay Time(s) Stab.(mV/s)

tests/test_gamryparser.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ def test_read_header(self):
3030
self.assertEqual(gp.header["CHECKSELECTOR"], 0)
3131
self.assertFalse(gp.header["CHECKTOGGLE"])
3232
self.assertTrue(isinstance(gp.header["CHECK2PARAM"], dict))
33-
self.assertTrue(gp.header["CHECK2PARAM"]["enable"])
34-
self.assertEqual(gp.header["CHECK2PARAM"]["start"], 300)
35-
self.assertEqual(gp.header["CHECK2PARAM"]["finish"], 0.5)
33+
self.assertTrue(gp.header["CHECK2PARAM"].get("enable", False))
34+
self.assertEqual(gp.header["CHECK2PARAM"].get("start"), 300)
35+
self.assertEqual(gp.header["CHECK2PARAM"].get("finish"), 0.5)
36+
37+
gp = parser.GamryParser(filename="tests/cv_data_incompleteheader.dta")
38+
_, count = gp.read_header()
39+
self.assertEqual(gp.header["DELAY"], dict(enable=False, start=300, finish=0.1))
3640

3741
def test_load(self):
3842
locale.setlocale(locale.LC_ALL, "")
@@ -52,6 +56,7 @@ def test_load(self):
5256
curve1 = gp.curves[0]
5357
self.assertEqual(curve1["T"].iloc[0], 0.1)
5458
self.assertEqual(curve1["T"].iloc[-1], 1.0)
59+
self.assertEqual(curve1["Vf"].iloc[-1], 0.5)
5560
self.assertEqual(curve1.index.dtype, np.int64)
5661

5762
curve5 = gp.curves[-1]

tox.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[tox]
2+
envlist = py{36,37,38,39}
3+
4+
[gh-actions]
5+
python =
6+
3.6: py36
7+
3.7: py37
8+
3.8: py38
9+
3.9: py39
10+
11+
[testenv]
12+
deps =
13+
pytest
14+
coverage
15+
16+
commands = coverage erase
17+
coverage run {envbindir}/pytest
18+
coverage report --omit=*test*

0 commit comments

Comments
 (0)