Skip to content

Commit 475967a

Browse files
committed
TST: save file to temp dir
1 parent cd4b809 commit 475967a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libpysal/weights/tests/test_weights.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
import tempfile
3+
14
import unittest
25
from ..weights import W, WSP
36
from .. import util
@@ -346,8 +349,10 @@ def test_connected_components(self):
346349
assert disco.n_components == 2
347350

348351
def test_roundtrip_write(self):
349-
self.w.to_file("./tmp.gal")
350-
new = W.from_file("./tmp.gal")
352+
with tempfile.TemporaryDirectory() as tmpdir:
353+
path = os.path.join(str(tmpdir), "tmp.gal")
354+
self.w.to_file(path)
355+
new = W.from_file(path)
351356
np.testing.assert_array_equal(self.w.sparse.toarray(), new.sparse.toarray())
352357

353358

0 commit comments

Comments
 (0)