File: test_pyinstaller.py

package info (click to toggle)
python-eliot 1.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: python: 8,641; makefile: 151
file content (35 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Test for pyinstaller compatibility."""

from unittest import TestCase, SkipTest
from tempfile import mkdtemp, NamedTemporaryFile
from subprocess import check_call, CalledProcessError
import os


class PyInstallerTests(TestCase):
    """Make sure PyInstaller doesn't break Eliot."""

    def setUp(self):
        try:
            check_call(["pyinstaller", "--help"])
        except (CalledProcessError, FileNotFoundError):
            raise SkipTest("Can't find pyinstaller.")

    def test_importable(self):
        """The Eliot package can be imported inside a PyInstaller packaged binary."""
        output_dir = mkdtemp()
        with NamedTemporaryFile(mode="w") as f:
            f.write("import eliot; import eliot.prettyprint\n")
            f.flush()
            check_call(
                [
                    "pyinstaller",
                    "--distpath",
                    output_dir,
                    "-F",
                    "-n",
                    "importeliot",
                    f.name,
                ]
            )
        check_call([os.path.join(output_dir, "importeliot")])