diff --git a/tests/gobj/test_texture_pool.py b/tests/gobj/test_texture_pool.py index b07e8a0cb9..c8ac5ae44a 100644 --- a/tests/gobj/test_texture_pool.py +++ b/tests/gobj/test_texture_pool.py @@ -22,8 +22,10 @@ def image_rgb_path(): "Generates an RGB image." file = tempfile.NamedTemporaryFile(suffix='-rgb.png') - write_image(file.name, 3) - yield file.name + path = core.Filename.from_os_specific(file.name) + path.make_true_case() + write_image(path, 3) + yield path file.close() @@ -32,8 +34,10 @@ def image_rgba_path(): "Generates an RGBA image." file = tempfile.NamedTemporaryFile(suffix='-rgba.png') - write_image(file.name, 4) - yield file.name + path = core.Filename.from_os_specific(file.name) + path.make_true_case() + write_image(path, 4) + yield path file.close() @@ -42,8 +46,10 @@ def image_gray_path(): "Generates a grayscale image." file = tempfile.NamedTemporaryFile(suffix='-gray.png') - write_image(file.name, 1) - yield file.name + path = core.Filename.from_os_specific(file.name) + path.make_true_case() + write_image(path, 1) + yield path file.close() diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py index 7919a1360f..751ea0dc03 100644 --- a/tests/putil/test_datagram.py +++ b/tests/putil/test_datagram.py @@ -1,6 +1,7 @@ import pytest from panda3d import core import sys +import tempfile # Fixtures for generating interesting datagrams (and verification functions) on # the fly... @@ -147,30 +148,39 @@ def do_file_test(dg, verify, filename): dgi = core.DatagramIterator(dg2) verify(dgi) -def test_file_small(datagram_small, tmpdir): +@pytest.fixture +def tmpfile(): + file = tempfile.NamedTemporaryFile(suffix='.bin') + yield file + file.close() + +def test_file_small(datagram_small, tmpfile): """This tests DatagramOutputFile/DatagramInputFile on small datagrams.""" dg, verify = datagram_small - p = tmpdir.join('datagram.bin') - filename = core.Filename.from_os_specific(str(p)) + file = tempfile.NamedTemporaryFile(suffix='.bin') + filename = core.Filename.from_os_specific(file.name) + filename.make_true_case() do_file_test(dg, verify, filename) -def test_file_large(datagram_large, tmpdir): +def test_file_large(datagram_large, tmpfile): """This tests DatagramOutputFile/DatagramInputFile on very large datagrams.""" dg, verify = datagram_large - p = tmpdir.join('datagram.bin') - filename = core.Filename.from_os_specific(str(p)) + file = tempfile.NamedTemporaryFile(suffix='.bin') + filename = core.Filename.from_os_specific(file.name) + filename.make_true_case() do_file_test(dg, verify, filename) -def test_file_corrupt(datagram_small, tmpdir): +def test_file_corrupt(datagram_small, tmpfile): """This tests DatagramInputFile's handling of a corrupt size header.""" dg, verify = datagram_small - p = tmpdir.join('datagram.bin') - filename = core.Filename.from_os_specific(str(p)) + file = tempfile.NamedTemporaryFile(suffix='.bin') + filename = core.Filename.from_os_specific(file.name) + filename.make_true_case() dof = core.DatagramOutputFile() dof.open(filename) @@ -178,9 +188,9 @@ def test_file_corrupt(datagram_small, tmpdir): dof.close() # Corrupt the size header to 1GB - with p.open(mode='r+b') as f: - f.seek(0) - f.write(b'\xFF\xFF\xFF\x4F') + file.seek(0) + file.write(b'\xFF\xFF\xFF\x4F') + file.flush() dg2 = core.Datagram() dif = core.DatagramInputFile() @@ -190,8 +200,7 @@ def test_file_corrupt(datagram_small, tmpdir): # Truncate the file for size in [12, 8, 4, 3, 2, 1, 0]: - with p.open(mode='r+b') as f: - f.truncate(size) + file.truncate(size) dg2 = core.Datagram() dif = core.DatagramInputFile()