Skip to content

Commit 8485358

Browse files
committed
add unit test for SAS CPORT check
1 parent 5b43e1b commit 8485358

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pandas/tests/io/sas/data/DEMO_PUF.cpt

694 Bytes
Binary file not shown.

pandas/tests/io/sas/test_xport.py

+9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def setup_method(self, datapath):
3030
self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt")
3131
self.file03 = os.path.join(self.dirpath, "DRXFCD_G.xpt")
3232
self.file04 = os.path.join(self.dirpath, "paxraw_d_short.xpt")
33+
self.file05 = os.path.join(self.dirpath, "DEMO_PUF.cpt")
3334

3435
with td.file_leak_context():
3536
yield
@@ -157,3 +158,11 @@ def test_truncated_float_support(self):
157158

158159
data = read_sas(self.file04, format="xport")
159160
tm.assert_frame_equal(data.astype("int64"), data_csv)
161+
162+
def test_cport_header_found_raises(self):
163+
# Test with DEMO_PUF.cpt, the beginning of puf2019_1_fall.xpt
164+
# from https://www.cms.gov/files/zip/puf2019.zip
165+
# (despite the extension, it's a cpt file)
166+
msg = "Header record indicates a CPORT file, which is not readable."
167+
with pytest.raises(ValueError, match=msg):
168+
read_sas(self.file05, format="xport")

0 commit comments

Comments
 (0)