Skip to content

Commit

Permalink
added unittest for extra_date_formats
Browse files Browse the repository at this point in the history
  • Loading branch information
ofajardo committed Jan 30, 2023
1 parent d9ab0fb commit fe40f98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Binary file added test_data/basic/date_test.sas7bdat
Binary file not shown.
9 changes: 8 additions & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# #############################################################################

from datetime import datetime, timedelta
from datetime import datetime, timedelta, date
import unittest
import os
import sys
Expand Down Expand Up @@ -909,6 +909,13 @@ def test_sas7bdat_file_label_linux(self):
self.assertEqual(meta.file_label, "mytest label")
self.assertEqual(meta.table_name, "TEST_DATA")

def test_sas7bdat_extra_date_formats(self):
"testing extra date format argument"
path = os.path.join(self.basic_data_folder, "date_test.sas7bdat")
df, meta = pyreadstat.read_sas7bdat(path, extra_date_formats=["MMYY", "YEAR"])
self.assertEqual(df['yr'].iloc[0], date(2023,1,1))
self.assertEqual(df['dtc4'].iloc[0], date(2023,7,1))

def test_sas7bdat_file_label_windows(self):
"testing file label for file produced on windows"
path = os.path.join(self.basic_data_folder, "test_file_label_win.sas7bdat")
Expand Down

0 comments on commit fe40f98

Please sign in to comment.