Skip to content

Commit 1b5fc77

Browse files
committed
add get_random_path fixture randomize path
1 parent 4ac9488 commit 1b5fc77

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

pandas/tests/frame/test_to_csv.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
'int32', 'int64']
3131

3232

33+
@pytest.fixture
34+
def get_random_path():
35+
return u'__%s__' % tm.rands(10)
36+
37+
3338
class TestDataFrameToCSV(TestData):
3439

3540
def read_csv(self, path, **kwargs):
@@ -919,13 +924,13 @@ def test_to_csv_path_is_none(self):
919924
recons = pd.read_csv(StringIO(csv_str), index_col=0)
920925
assert_frame_equal(self.frame, recons)
921926

922-
def test_to_csv_compression(self, compression):
927+
def test_to_csv_compression(self, compression, get_random_path):
923928

924929
df = DataFrame([[0.123456, 0.234567, 0.567567],
925930
[12.32112, 123123.2, 321321.2]],
926931
index=['A', 'B'], columns=['X', 'Y', 'Z'])
927932

928-
with ensure_clean() as filename:
933+
with ensure_clean(get_random_path) as filename:
929934

930935
df.to_csv(filename, compression=compression)
931936

pandas/tests/series/test_io.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
from .common import TestData
1919

2020

21+
@pytest.fixture
22+
def get_random_path():
23+
return u'__%s__' % tm.rands(10)
24+
25+
2126
class TestSeriesToCSV(TestData):
2227

2328
def read_csv(self, path, **kwargs):
@@ -138,12 +143,12 @@ def test_to_csv_path_is_none(self):
138143
csv_str = s.to_csv(path=None)
139144
assert isinstance(csv_str, str)
140145

141-
def test_to_csv_compression(self, compression):
146+
def test_to_csv_compression(self, compression, get_random_path):
142147

143148
s = Series([0.123456, 0.234567, 0.567567], index=['A', 'B', 'C'],
144149
name='X')
145150

146-
with ensure_clean() as filename:
151+
with ensure_clean(get_random_path) as filename:
147152

148153
s.to_csv(filename, compression=compression, header=True)
149154

0 commit comments

Comments
 (0)