Skip to content

Commit

Permalink
tests: add more tests for bdist_msi (#2248)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotduarte committed Feb 8, 2024
1 parent 2b7f36e commit ba22e45
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 11 deletions.
82 changes: 72 additions & 10 deletions tests/test_command_bdist_msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sysconfig import get_platform

import pytest
from generate_samples import run_command
from generate_samples import create_package, run_command
from setuptools import Distribution

bdist_msi = pytest.importorskip(
Expand All @@ -22,15 +22,6 @@
SAMPLES_DIR = Path(__file__).resolve().parent.parent / "samples"


@pytest.mark.datafiles(SAMPLES_DIR / "msi_binary_data")
def test_bdist_msi(datafiles: Path):
"""Test the msi_binary_data sample."""
run_command(datafiles, "python setup.py bdist_msi")
platform = get_platform().replace("win-amd64", "win64")
file_created = datafiles / "dist" / f"hello-0.1-{platform}.msi"
assert file_created.is_file()


def test_bdist_msi_target_name():
"""Test the bdist_msi with extra target_name option."""
dist = Distribution(DIST_ATTRS)
Expand All @@ -52,6 +43,15 @@ def test_bdist_msi_target_name_and_version():
assert cmd.fullname == "mytest-0.1"


@pytest.mark.datafiles(SAMPLES_DIR / "msi_binary_data")
def test_bdist_msi_default(datafiles: Path):
"""Test the msi_binary_data sample."""
run_command(datafiles, "python setup.py bdist_msi")
platform = get_platform().replace("win-amd64", "win64")
file_created = datafiles / "dist" / f"hello-0.1-{platform}.msi"
assert file_created.is_file()


@pytest.mark.datafiles(SAMPLES_DIR / "msi_binary_data")
def test_bdist_msi_target_name_with_extension(datafiles: Path):
"""Test the msi_binary_data sample, with a specified target_name that
Expand All @@ -63,3 +63,65 @@ def test_bdist_msi_target_name_with_extension(datafiles: Path):
)
file_created = datafiles / "dist" / msi_name
assert file_created.is_file()


@pytest.mark.datafiles(SAMPLES_DIR / "advanced")
def test_bdist_msi_advanced(datafiles: Path):
"""Test the advanced sample."""
msi_name = "output.msi"
run_command(
datafiles, f"python setup.py bdist_msi --target-name {msi_name}"
)
file_created = datafiles / "dist" / msi_name
assert file_created.is_file()


@pytest.mark.datafiles(SAMPLES_DIR / "asmodule")
def test_bdist_msi_asmodule(datafiles: Path):
"""Test the asmodule sample."""
msi_name = "output.msi"
run_command(
datafiles, f"python setup.py bdist_msi --target-name {msi_name}"
)
file_created = datafiles / "dist" / msi_name
assert file_created.is_file()


@pytest.mark.datafiles(SAMPLES_DIR / "sqlite")
def test_bdist_msi_sqlite(datafiles: Path):
"""Test the sqlite sample."""
msi_name = "output.msi"
run_command(
datafiles, f"python setup.py bdist_msi --target-name {msi_name}"
)
file_created = datafiles / "dist" / msi_name
assert file_created.is_file()


SOURCE_HELLO = """
hello.py
import pkg.hi
print("Hello from cx_Freeze")
setup.py
from cx_Freeze import Executable, setup
setup(
name="hello",
version="0.1.2.3",
description="Sample cx_Freeze script",
executables=[Executable("hello.py")],
)
pkg/hi.py
print("Hi!")
"""


def test_bdist_msi_advanced2(tmp_path: Path):
"""Test the executables option."""
create_package(tmp_path, SOURCE_HELLO)
msi_name = "output.msi"
run_command(
tmp_path, f"python setup.py bdist_msi --target-name {msi_name}"
)
file_created = tmp_path / "dist" / msi_name
assert file_created.is_file()
1 change: 0 additions & 1 deletion tests/test_executables.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def test_executables(tmp_path: Path, source: str, number_of_executables: int):
"""Test the executables option."""
create_package(tmp_path, source)
output = run_command(tmp_path)
print(output)

for i in range(1, number_of_executables):
file_created = tmp_path / BUILD_EXE_DIR / f"test_simple{i}{SUFFIX}"
Expand Down

0 comments on commit ba22e45

Please sign in to comment.