fixed assertion and context manager
@@ -13,14 +13,10 @@ import numpy
class TestText(unittest.TestCase):
def test_savetxt(self):
+ with (tempfile.NamedTemporaryFile() as tmp_cupy,
+ tempfile.NamedTemporaryFile() as tmp_numpy):
array = [[1, 2, 3], [2, 3, 4]]
- tmp_cupy = tempfile.NamedTemporaryFile('w+t')
- tmp_cupy.name = "test_cupy.txt"
- tmp_numpy = tempfile.NamedTemporaryFile('w+t')
- tmp_numpy.name = "test_numpy.txt"
cupy.savetxt(tmp_cupy.name, cupy.array(array))
numpy.savetxt(tmp_numpy.name, numpy.array(array))
- assert filecmp.cmp(tmp_cupy.name, tmp_numpy.name) is True
- os.remove(str(tmp_cupy.name))
- os.remove(str(tmp_numpy.name))
+ assert filecmp.cmp(tmp_cupy.name, tmp_numpy.name)
pass
