test_binary.py (1574B)
1 import os 2 3 import mozinfo 4 import mozinstall 5 import mozunit 6 import pytest 7 8 9 @pytest.mark.skipif( 10 mozinfo.isWin, 11 reason="Bug 1157352 - New firefox.exe needed for mozinstall 1.12 and higher.", 12 ) 13 def test_get_binary(tmpdir, get_installer): 14 """Test to retrieve binary from install path.""" 15 if mozinfo.isLinux: 16 installdir = mozinstall.install(get_installer("tar.xz"), tmpdir.strpath) 17 binary = os.path.join(installdir, "firefox") 18 19 assert mozinstall.get_binary(installdir, "firefox") == binary 20 21 elif mozinfo.isWin: 22 installdir_exe = mozinstall.install( 23 get_installer("exe"), tmpdir.join("exe").strpath 24 ) 25 binary_exe = os.path.join(installdir_exe, "core", "firefox.exe") 26 27 assert mozinstall.get_binary(installdir_exe, "firefox") == binary_exe 28 29 installdir_zip = mozinstall.install( 30 get_installer("zip"), tmpdir.join("zip").strpath 31 ) 32 binary_zip = os.path.join(installdir_zip, "firefox.exe") 33 34 assert mozinstall.get_binary(installdir_zip, "firefox") == binary_zip 35 36 elif mozinfo.isMac: 37 installdir = mozinstall.install(get_installer("dmg"), tmpdir.strpath) 38 binary = os.path.join(installdir, "Contents", "MacOS", "firefox") 39 40 assert mozinstall.get_binary(installdir, "firefox") == binary 41 42 43 def test_get_binary_error(tmpdir): 44 """Test that an InvalidBinary error is raised.""" 45 with pytest.raises(mozinstall.InvalidBinary): 46 mozinstall.get_binary(tmpdir.strpath, "firefox") 47 48 49 if __name__ == "__main__": 50 mozunit.main()