MCPcopy
hub / github.com/pandas-dev/pandas / test_nonfile_writing

Method test_nonfile_writing

pandas/tests/io/test_stata.py:1847–1862  ·  view source on GitHub ↗
(self, version, temp_file)

Source from the content-addressed store, hash-verified

1845
1846 @pytest.mark.parametrize("version", [114, 117, 118, 119, None])
1847 def test_nonfile_writing(self, version, temp_file):
1848 # GH 21041
1849 bio = io.BytesIO()
1850 df = DataFrame(
1851 1.1 * np.arange(120).reshape((30, 4)),
1852 columns=pd.Index(list("ABCD")),
1853 index=pd.Index([f"i-{i}" for i in range(30)]),
1854 )
1855 df.index.name = "index"
1856 path = temp_file
1857 df.to_stata(bio, version=version)
1858 bio.seek(0)
1859 with open(path, "wb") as dta:
1860 dta.write(bio.read())
1861 reread = read_stata(path, index_col="index")
1862 tm.assert_frame_equal(df, reread)
1863
1864 def test_gzip_writing(self, temp_file):
1865 # writing version 117 requires seek and cannot be used with gzip

Callers

nothing calls this directly

Calls 7

to_stataMethod · 0.95
DataFrameClass · 0.90
read_stataFunction · 0.90
reshapeMethod · 0.45
seekMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected