From bcd7c5a9b802391e07ec67a533883376f35dacb9 Mon Sep 17 00:00:00 2001 From: Chris Kerr Date: Sat, 3 Jul 2021 16:08:48 +0300 Subject: [PATCH] Add a test for the parse_BioLogic_date function --- tests/test_BioLogic.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/test_BioLogic.py b/tests/test_BioLogic.py index 76e65e8..c4ddca0 100644 --- a/tests/test_BioLogic.py +++ b/tests/test_BioLogic.py @@ -6,7 +6,7 @@ import os.path import re -from datetime import datetime +from datetime import date, datetime import numpy as np from numpy.testing import assert_array_almost_equal, assert_array_equal @@ -77,6 +77,24 @@ def test_colID_to_dtype(colIDs, expected): assert dtype == expected_dtype +@pytest.mark.parametrize('data, expected', [ + ('02/23/17', date(2017, 2, 23)), + ('10-03-05', date(2005, 10, 3)), + ('11.12.20', date(2020, 11, 12)), + (b'01/02/03', date(2003, 1, 2)), + ('13.08.07', ValueError), + ('03-04/05', ValueError), +]) +def test_parse_BioLogic_date(data, expected): + """Test the parse_BioLogic_date function.""" + if isinstance(expected, type) and issubclass(expected, Exception): + with pytest.raises(expected): + BioLogic.parse_BioLogic_date(data) + return + result = BioLogic.parse_BioLogic_date(data) + assert result == expected + + @pytest.mark.parametrize('filename, startdate, enddate', [ ('bio_logic1.mpr', '2011-10-29', '2011-10-31'), ('bio_logic2.mpr', '2012-09-27', '2012-09-27'),