Skip to content

Commit

Permalink
Merge pull request #349 from lazka/fix-file-leaks
Browse files Browse the repository at this point in the history
tests: Fix file leaks
  • Loading branch information
lazka authored Oct 21, 2023
2 parents 6ff2866 + 45b3e97 commit 31f3000
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: |
export SETUPTOOLS_USE_DISTUTILS=stdlib
export CFLAGS="-std=c90 -Wall -Wno-long-long -Werror -coverage"
python -m coverage run --branch setup.py test
PYTHONDEVMODE=1 python -m coverage run --branch setup.py test
python -m coverage xml -i
python setup.py sdist
python setup.py bdist_wheel
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Build & Test with setuptools
run: |
export CFLAGS="-Werror -coverage"
python -m coverage run --branch setup.py test
PYTHONDEVMODE=1 python -m coverage run --branch setup.py test
python -m coverage xml -i
python setup.py sdist
python setup.py bdist_wheel
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
python -m pip install --upgrade pytest flake8 coverage hypothesis
if (-not $?) { exit 1 }
python -m pip install --upgrade pygame
python -m coverage run --branch setup.py test
python -X dev -m coverage run --branch setup.py test
if (-not $?) { exit 1 }
python -m coverage xml -i
if (-not $?) { exit 1 }
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:
- name: Build & Test with setuptools
run: |
python3 -m coverage run --branch setup.py test
PYTHONDEVMODE=1 python3 -m coverage run --branch setup.py test
python3 -m coverage xml -i
python3 setup.py sdist
python3 setup.py install --root="$(pwd)"/_root_abs
Expand Down
16 changes: 8 additions & 8 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import io
import sys
import tempfile as tfi
import tempfile
import base64
import zlib
import shutil
Expand Down Expand Up @@ -50,7 +50,7 @@ def test_unicode_filenames():
# missing under Python 3

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
dirname = tfi.mkdtemp()
dirname = tempfile.mkdtemp()
old_dir = os.getcwd()
try:
os.chdir(dirname)
Expand Down Expand Up @@ -90,17 +90,17 @@ def test_surface():
assert s.get_width() == w
assert s.get_height() == h

f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100
s = cairo.PDFSurface(f, w, h)
with tempfile.TemporaryFile(mode='w+b') as f:
cairo.PDFSurface(f, 100, 100)

f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100
s = cairo.PSSurface(f, w, h)
with tempfile.TemporaryFile(mode='w+b') as f:
cairo.PSSurface(f, 100, 100)

s = cairo.RecordingSurface(cairo.CONTENT_COLOR, None)
s = cairo.RecordingSurface(cairo.CONTENT_COLOR, (1, 1, 10, 10))

f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100
s = cairo.SVGSurface(f, w, h)
with tempfile.TemporaryFile(mode='w+b') as f:
cairo.SVGSurface(f, 100, 100)


def test_surface_destroy_before_context():
Expand Down

0 comments on commit 31f3000

Please sign in to comment.