Skip to content

Commit

Permalink
Demonstrate that the wheel builder does not close wheels explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed Jan 7, 2021
1 parent 79bc4cb commit 8997e3a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/masonry/builders/test_wheel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import os
import shutil
import zipfile

Expand Down Expand Up @@ -270,3 +271,24 @@ def test_default_src_with_excluded_data(mocker):
assert "my_package/data/data1.txt" in names
assert "my_package/data/sub_data/data2.txt" not in names
assert "my_package/data/sub_data/data3.txt" in names


def test_wheel_file_is_closed(monkeypatch):
"""Confirm that wheel zip files are explicitly closed."""

# Using a list is a hack for Python 2.7 compatibility.
fd_file = [None]

real_fdopen = os.fdopen

def capturing_fdopen(*args, **kwargs):
fd_file[0] = real_fdopen(*args, **kwargs)
return fd_file[0]

monkeypatch.setattr(os, "fdopen", capturing_fdopen)

module_path = fixtures_dir / "module1"
WheelBuilder.make(Factory().create_poetry(module_path))

assert fd_file[0] is not None
assert fd_file[0].closed

0 comments on commit 8997e3a

Please sign in to comment.