Repository: bcliang/gamry-parser (language: python)

Issue:
CI: setuptools test method has been deprecated. Migrate to other testrunner for unittests
Couple years old now, but `setup.py test` and the `test_suite` property have been deprecated. The setuptools recommendation is to migrate to `tox` 

https://tox.readthedocs.io/en/latest/example/basic.html#a-simple-tox-ini-default-environments


Discussion / hints:

Fix patch:
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..76b1118
--- /dev/null
+++ b/.coveragerc
@@ -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
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 271dfca..f9248b5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
 -
diff --git a/README.md b/README.md
index a80f9cb..3fda6cd 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 13ea16e..96a2698 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,2 +1,2 @@
 setuptools
-coverage
+pytest
\ No newline at end of file
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..40e4116
--- /dev/null
+++ b/tox.ini
@@ -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*


Test patch:
diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml
index 49cc578..73ab345 100644
--- a/.github/workflows/unittest.yml
+++ b/.github/workflows/unittest.yml
@@ -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
@@ -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
\ No newline at end of file
diff --git a/tests/cv_data_incompleteheader.dta b/tests/cv_data_incompleteheader.dta
new file mode 100644
index 0000000..53b58a2
--- /dev/null
+++ b/tests/cv_data_incompleteheader.dta
@@ -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)
\ No newline at end of file
diff --git a/tests/test_gamryparser.py b/tests/test_gamryparser.py
index 8362951..9007268 100644
--- a/tests/test_gamryparser.py
+++ b/tests/test_gamryparser.py
@@ -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, "")
@@ -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]