def test_esky_bundle_mscrvt(): setup, options, new_script = esky_setup('Simple Working', WORKING_SCRIPT) # setup(**options) new_script2 = make_new_script_name('testing_patching.py') insert_code(new_script2, 'import sys', 'import os', 'versiondir = os.path.dirname(sys.executable)', 'for nm in os.listdir(versiondir):', ' if nm.startswith("Microsoft.") and nm.endswith(".CRT"):', ' msvcrt_dir = os.path.join(versiondir,nm)', ' assert os.path.isdir(msvcrt_dir)', ' assert len(os.listdir(msvcrt_dir)) >= 2', ' break', 'else:', ' assert False, "MSVCRT not bundled in version dir "+versiondir') options2 = copy.deepcopy(options) options2['options']['bdist_esky']['bundle_msvcrt'] = True options2['scripts'] = [new_script2] # options2['script_args'] = ['bdist_esky_patch'] options2['version'] = '2.0' setup(**options2) # esky_zip_name = 'Simple Working-0.2.win32.zip' esky_zip_name = get_zip_name(options2) clean_exit, stderr = run_script(new_script2, freezer='esky', zip_name=esky_zip_name) assert clean_exit
def test_multiple_runs_of_setup_function(): '''make sure our fixes support multiple runs ''' from esky.bdist_esky import Executable setup, options, new_script = esky_setup('Simple Working', WORKING_SCRIPT) new_script2 = make_new_script_name('test_multiple_working.py') insert_code(new_script2,'import sys') options2 = copy.deepcopy(options) options2['scripts'] = [new_script2] options2['version'] = '0.2' esky_zip_name = get_zip_name(options2) # Now test that freeze future works as well cleanup_dirs() setup(**options) clean_exit, stderr = run_script(new_script, freezer='esky') assert clean_exit # only works if we cleanup dirs.. same as original esky cleanup_dirs() setup(**options2) if os.name == 'nt': platform = get_platform() esky_zip_name = 'Simple Working-0.2.%s.zip' % platform clean_exit, stderr = run_script(new_script2, freezer='esky', zip_name=esky_zip_name) assert clean_exit
def test_cxfreeze_failure_condition(): '''Our script fails to build under certain platforms and python versions due to dependancies not being found by our freezer, we need to manually include/exclude them''' setup, options, new_script = cxfreeze_setup('test_condition', 'test_condition.py') insert_code( new_script, "from future import standard_library", "standard_library.install_aliases()", ) if 'linux' in sys.path or 'darwin' in sys.platform: #TODO confirm that mac handles the same as linux.. if not PY3: with pytest.raises(Exception): setup(**options) else: setup(**options) elif sys.platform == 'win32': setup(**options) clean_exit, stderr = run_script(new_script, freezer='cxfreeze') if PY3: assert clean_exit else: #this failure condition is from cxfreeze and py2exe.. missing modules .. assert not clean_exit
def test_py2app_future_condition_3_fix(): '''tests our fix when importing everything under the sun!''' setup, options, new_script = py2app_setup('py2app fixed', 'py2app_fixed.py') insert_code(new_script, 'import past') freeze_future.setup(**options) clean_exit, stderr = run_script(new_script, freezer='py2app') assert clean_exit
def test_py2exe_failure_condition2(): '''this module was playing up so testing it ..''' setup, options, new_script = py2exe_setup('test_condition2', 'test_condition2.py') insert_code(new_script, "from __future__ import print_function",) setup(**options) clean_exit, stderr = run_script(new_script, freezer='py2exe') assert clean_exit
def test_setuptools_return_when_using_future(): '''Tests that a script with the future imports runs as normal''' setup, options, new_script = setuptools_setup('should run the setup stuff', 'disturils_return_working.py') insert_code(new_script, "from __future__ import print_function", "from future import standard_library", "standard_library.install_aliases()") assert freeze_future.setup(**options) == False
def test_esky_freeze_future_condition_three_fix(): '''explictly telling freeze future we are using esky and cxfreeze''' setup, options, new_script = esky_setup('cxfreeze_esky_fixed', 'esky_cxfreeze_fixed.py') insert_code(new_script, "import past",) setup(**options) clean_exit, stderr = run_script(new_script, freezer='esky') assert clean_exit
def test_py2app_failure_condition2(): '''this module was playing up so testing it ..''' setup, options, new_script = py2app_setup('test_condition2', 'test_condition2.py') insert_code(new_script, "from __future__ import print_function",) setup(**options) clean_exit, stderr = run_script(new_script, freezer='py2app') assert clean_exit
def test_cxfreeze_future_condition_3_fix(): '''tests our fix when importing everything under the sun! also import builtins TBD this test is a bit flakey when running the entire suite and doing tests on py 2 and py3''' setup, options, new_script = cxfreeze_setup('cxfreeze fixed', 'cxfreeze_fixed.py') insert_code(new_script, 'import past') freeze_future.setup(**options) clean_exit, stderr = run_script(new_script, freezer='cxfreeze') assert clean_exit
def test_freeze_future_running_when_using_future_with_cxfreeze(): '''Tests that a script with the future imports gets recognized and the freeze future code is run''' setup, options, new_script = cxfreeze_setup('should run the setup stuff', 'cxfreeze_reuturn_working.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()") if PY3: assert freeze_future.setup(test_setup=True, **options) == False else: assert freeze_future.setup(test_setup=True, **options) == True
def test_esky_failure_condition2_fixed(): '''this error isn't mine to fix here, it is not present in the freezers o.0''' setup, options, new_script = esky_setup('test_condition2', 'test_condition2.py') insert_code(new_script, "from __future__ import print_function",) fail_cond = 'The process cannot access the file because it is being used by another process' setup(**options) clean_exit, stderr = run_script(new_script, freezer='esky') assert clean_exit
def test_esky_failure_condition_fixed(): setup, options, new_script = esky_setup('test_condition', 'test_condition.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()",) setup(**options) clean_exit, stderr = run_script(new_script, freezer='esky') assert clean_exit
def test_setuptools_condition2(): '''Testing adding the future imports doesn't f**k up the building''' setup, options, new_script = setuptools_setup('Working with Future Import', 'future_working.py') insert_code(new_script, "from __future__ import print_function") setup(**options) clean_exit, stderr = run_script(new_script, freezer='setuptools') assert clean_exit
def test_freeze_future_running_when_using_future_with_py2app(): '''Tests that a script with the future imports gets recognized and the freeze future code is run''' setup, options, new_script = py2app_setup('should run the setup stuff', 'py2app_reuturn_working.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()") if PY3: assert freeze_future.setup(test_setup=True, **options) == False else: assert freeze_future.setup(test_setup=True, **options) == True
def test_cxfreeze_failure_condition3(): ''' basically using open function on a datafile will fail if the modulea and datafiles are inside a zip as open doesn't know how to look in a zip. Error -> No such file or directory grammer.txt https://bitbucket.org/anthony_tuininga/cx_freeze/issues/151/using-modules-that-use-open-on-data-files''' setup, options, new_script = cxfreeze_setup('test_condition3', 'test_condition3.py') insert_code(new_script, "import past") # 'from past.builtins import basestring') setup(**options) clean_exit, stderr = run_script(new_script, freezer='cxfreeze') assert not clean_exit
def test_py2app_failure_condition3_fixed(): ''' basically using open function on a datafile will fail if the modulea and datafiles are inside a zip as open doesn't know how to look in a zip. Error -> No such file or directory grammer.txt https://bitbucket.org/anthony_tuininga/cx_freeze/issues/151/using-modules-that-use-open-on-data-files''' setup, options, new_script = py2app_setup('test_condition3', 'test_condition3.py') insert_code(new_script, "import past") # 'from past.builtins import basestring') setup(**options) clean_exit, stderr = run_script(new_script, freezer='py2app') assert clean_exit
def test_freeze_future_running_when_using_future_with_py2exe(): '''Tests that a script with the future imports gets recognized and we run our code''' setup, options, new_script = py2exe_setup('should run the setup stuff', 'py2exe_return_test.py') insert_code(new_script, "from __future__ import print_function", "from future import standard_library", "standard_library.install_aliases()") if PY3: assert freeze_future.setup(test_setup=True, **options) == False else: assert freeze_future.setup(test_setup=True, **options) == True
def test_py2app_failure_condition(): '''Our script fails to build under certain platforms and python versions due to dependancies not being found by our freezer, we need to manually include/exclude them''' setup, options, new_script = py2app_setup('test_condition', 'test_condition.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()",) if 'darwin' in sys.platform: #TODO confirm that mac handles the same as linux.. if not PY3: with pytest.raises(Exception): setup(**options) else: setup(**options)
def test_py2app_freeze_future_condition_one_fix(): '''tests our fix when importing everything under the sun!, just another sanity check''' setup, options, new_script = py2app_setup('py2app fixed', 'py2app_fixed.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()", "import urllib.request, urllib.error, urllib.parse", "import collections", "from itertools import filterfalse", "from subprocess import getoutput", "from builtins import str", "from builtins import range",) freeze_future.setup(**options) clean_exit, stderr = run_script(new_script, freezer='py2app') assert clean_exit
def test_py2app_work_with_no_standard_library(): '''does our code with without the standard librar function call''' setup, options, new_script = py2app_setup('py2app works_nostandardlin', 'py2app_works_no_stdlib.py') insert_code(new_script, "from __future__ import absolute_import, division, print_function", "from builtins import (bytes, str, open, super, range,", " zip, round, input, int, pow, object)") freeze_future.setup(**options) if PY3: clean_exit, stderr = run_script(new_script, freezer='py2app') assert clean_exit else: #with pytest.raises(Exception):# I think my exit code is shadowing the exception or sth?? or my sys.exit call clean_exit, stderr = run_script(new_script, freezer='py2app') assert clean_exit
def test_py2exe_future_condition_3_fix(): '''tests our fix when importing everything under the sun! also import builtins TBD this test is a bit flakey when running the entire suite and doing tests on py 2 and py3''' setup, options, new_script = py2exe_setup('py2exe fixed', 'py2exe_fixed.py') insert_code(new_script, 'import past') freeze_future.setup(**options) clean_exit, stderr = run_script(new_script, freezer='py2exe') if not clean_exit: with open(r'dist/py2exe_fixed.log', newline='\n') as log: from pprint import pprint pprint(log.readlines()) import pdb;pdb.set_trace() assert clean_exit
def test_esky_bdist_esky_patch_command(): '''this test is overkill just need to make sure patch command returns esky''' # TODO this made it clear i need to force the selection of freezer rather trying than smart detect it setup, options, new_script = esky_setup('Simple Working', WORKING_SCRIPT) setup(**options) new_script2 = make_new_script_name('testing_patching.py') insert_code(new_script2,'import sys') options2 = copy.deepcopy(options) options2['scripts'] = [new_script2] options2['script_args'] = ['bdist_esky_patch'] options2['version'] = '0.2' setup(**options2) esky_zip_name = get_zip_name(options2) clean_exit, stderr = run_script(new_script2, freezer='esky', zip_name=esky_zip_name) assert clean_exit
def test_py2exe_failure_condition(): ''' Testing adding the future imports doesn't f**k up the building on python3 F***s up python2 though''' setup, options, new_script = py2exe_setup('Working with Future Import', 'py2exe_future_working.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()") if PY3: with pytest.raises(AttributeError): setup(**options) else: setup(**options) clean_exit, stderr = run_script(new_script, freezer='py2exe') assert not clean_exit
def test_esky_freeze_future_condition_one_fix(): '''tests our fix when importing everything under the sun! also import builtins''' setup, options, new_script = esky_setup('esky fixed2', 'esky_fixed2.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()", "import urllib.request, urllib.error, urllib.parse", "import collections", "from itertools import filterfalse", "from subprocess import getoutput", "from builtins import str", "from builtins import range", "from queue import Queue") setup(**options) clean_exit, stderr = run_script(new_script, freezer='esky') assert clean_exit
def test_py2app_work_with_no_standard_library(): '''does our code with without the standard librar function call''' setup, options, new_script = py2app_setup('py2app works_nostandardlin', 'py2app_works_no_stdlib.py') insert_code( new_script, "from __future__ import absolute_import, division, print_function", "from builtins import (bytes, str, open, super, range,", " zip, round, input, int, pow, object)") freeze_future.setup(**options) if PY3: clean_exit, stderr = run_script(new_script, freezer='py2app') assert clean_exit else: #with pytest.raises(Exception):# I think my exit code is shadowing the exception or sth?? or my sys.exit call clean_exit, stderr = run_script(new_script, freezer='py2app') assert clean_exit
def test_py2app_failure_condition(): '''Our script fails to build under certain platforms and python versions due to dependancies not being found by our freezer, we need to manually include/exclude them''' setup, options, new_script = py2app_setup('test_condition', 'test_condition.py') insert_code( new_script, "from future import standard_library", "standard_library.install_aliases()", ) if 'darwin' in sys.platform: #TODO confirm that mac handles the same as linux.. if not PY3: with pytest.raises(Exception): setup(**options) else: setup(**options)
def test_setuptools_condition(): '''Testing adding the future imports doesn't f**k up the building''' setup, options, new_script = setuptools_setup('cxfreeze fixed', 'cxfreeze_fixed.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()", "import urllib.request, urllib.error, urllib.parse", "import collections", "from itertools import filterfalse", "from subprocess import getoutput", "from builtins import str", "from builtins import range",) setup(**options) clean_exit, stderr = run_script(new_script, freezer='setuptools') assert clean_exit
def test_esky_freeze_future_condition_two_fix(): ''' Testing adding the future imports doesn't f**k up the building on python3 F***s up python2 though Esky allows setup to compile, but the script will not run ''' setup, options, new_script = esky_setup('Working with Future Import', 'esky_future_working.py') insert_code(new_script, "from __future__ import print_function",) if PY3: freeze_future.setup(**options) clean_exit, stderr = run_script(new_script, freezer='esky') assert clean_exit else: freeze_future.setup(**options) clean_exit, stderr = run_script(new_script, freezer='esky') assert not clean_exit
def test_cxfreeze_freeze_future_condition_one_fix(): '''tests our fix when importing everything under the sun!, just another sanity check''' setup, options, new_script = cxfreeze_setup('cxfreeze fixed', 'cxfreeze_fixed.py') insert_code( new_script, "from future import standard_library", "standard_library.install_aliases()", "import urllib.request, urllib.error, urllib.parse", "import collections", "from itertools import filterfalse", "from subprocess import getoutput", "from builtins import str", "from builtins import range", ) freeze_future.setup(**options) clean_exit, stderr = run_script(new_script, freezer='cxfreeze') assert clean_exit
def test_cxfreeze_failure_condition(): '''Our script fails to build under certain platforms and python versions due to dependancies not being found by our freezer, we need to manually include/exclude them''' setup, options, new_script = cxfreeze_setup('test_condition', 'test_condition.py') insert_code(new_script, "from future import standard_library", "standard_library.install_aliases()",) if 'linux' in sys.path or 'darwin' in sys.platform: #TODO confirm that mac handles the same as linux.. if not PY3: with pytest.raises(Exception): setup(**options) else: setup(**options) elif sys.platform == 'win32': setup(**options) clean_exit, stderr = run_script(new_script, freezer='cxfreeze') if PY3: assert clean_exit else: #this failure condition is from cxfreeze and py2exe.. missing modules .. assert not clean_exit
def test_esky_patch(): '''need to have our esky fixes developed in freeze future moved to f_py2exe or f_cxfrexe etc for patchingo work''' tdir=os.getcwd() uzdir = os.path.join(tdir,"unzip") try: really_rmtree(uzdir) except Exception: pass setup, options, new_script = esky_setup('Simple Working', WORKING_SCRIPT) setup(**options) new_script2 = make_new_script_name('testing_patching.py') insert_code(new_script2,'import sys') options2 = copy.deepcopy(options) options2['scripts'] = [new_script2] options2['script_args'] = ['bdist_esky_patch'] options2['version'] = '2.0' options2['freezer'] = '2.0' setup(**options2) platform = get_platform() deep_extract_zipfile(os.path.join(tdir,"dist","Simple Working-1.0.%s.zip"%(platform,)),uzdir) with open(os.path.join(tdir,"dist","Simple Working-2.0.%s.from-1.0.patch"%(platform,)),"rb") as f: esky.patch.apply_patch(uzdir,f) filewithext = os.path.basename(new_script2) file = os.path.splitext(filewithext)[0] path_file = os.path.join(uzdir, file) cmd = [path_file] proc = subprocess.Popen(cmd, stderr=subprocess.PIPE) errs = proc.communicate() if not proc.returncode: exit_code = True else: exit_code = False assert exit_code really_rmtree(uzdir)