summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozinstall/tests/test_is_installer.py
blob: 8cba4395af8f46a449c32669a3f0c6215d7b0f2e (plain)
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
36
37
38
39
40
41
42
from __future__ import absolute_import

import mozinfo
import mozinstall
import mozunit
import pytest


@pytest.mark.skipif(
    mozinfo.isWin,
    reason="Bug 1157352 - New firefox.exe needed for mozinstall 1.12 and higher.",
)
def test_is_installer(request, get_installer):
    """Test that we can identify a correct installer."""
    if mozinfo.isLinux:
        assert mozinstall.is_installer(get_installer("tar.bz2"))

    if mozinfo.isWin:
        # test zip installer
        assert mozinstall.is_installer(get_installer("zip"))

        # test exe installer
        assert mozinstall.is_installer(get_installer("exe"))

        try:
            # test stub browser file
            # without pefile on the system this test will fail
            import pefile  # noqa

            stub_exe = (
                request.node.fspath.dirpath("build_stub").join("firefox.exe").strpath
            )
            assert not mozinstall.is_installer(stub_exe)
        except ImportError:
            pass

    if mozinfo.isMac:
        assert mozinstall.is_installer(get_installer("dmg"))


if __name__ == "__main__":
    mozunit.main()