pycode: helpers for unit tests and setup¶
packages¶
pyquickhelper.pycode.get_package_info
(name = None, start = 0, end = -1)
Calls
pip show
to retrieve information about packages.
pyquickhelper.pycode.get_packages_list
()
calls
pip list
to retrieve the list of packages
profiling¶
pyquickhelper.pycode.profiling.profile
(fct, sort = ‘cumulative’, rootrem = None, as_df = False, pyinst_format = None, return_results = False, kwargs)
Profiles the execution of a function.
pyquickhelper.pycode.profiling.profile2df
(ps, as_df = True, clean_text = None, verbose = False, fLOG = None)
Converts profiling statistics into a Dataframe.
pyquickhelper.pycode.profiling.profile2graph
(ps, clean_text = None, verbose = False, fLOG = None)
Converts profiling statistics into a graphs.
pyquickhelper.pycode.profiling.ProfileNode
(self, filename, line, func_name, nc1, nc2, tin, tall)
Graph structure to represent a profiling.
python2¶
pyquickhelper.pycode.py3to2.py3to2_convert
(script, unittest_modules)
converts a script into from python 3 to python 2
pyquickhelper.pycode.py3to2.py3to2_convert_tree
(folder, dest, encoding = ‘utf8’, pattern = ‘.*[.]py$’, pattern_copy = ‘.*[.]((ico)|(7z)|(dll)|(so)|(yml)|(rst)|(ipynb)|(gif)|(jpg)|(jpeg)|(png)|(txt)|(zip)|(gz)|(html)|(exe)|(js)|(css)|(tex)|(data)|(csv)|(tpl)|(tmpl))$’, unittest_modules = None, fLOG = <function noLOG at 0x7f5f8e8804c0>)
Converts files in a folder and its subfolders from python 3 to python 2, the function only considers python script (verifying pattern).
setup¶
pyquickhelper.pycode.available_commands_list
(argv)
Checks that on command handled by pyquickhelper is part of the arguments.
pyquickhelper.pycode.process_standard_options_for_setup
(argv, file_or_folder, project_var_name, module_name = None, unittest_modules = None, pattern_copy = None, requirements = None, port = 8067, blog_list = None, default_engine_paths = None, extra_ext = None, add_htmlhelp = False, coverage_options = None, coverage_exclude_lines = None, func_sphinx_begin = None, func_sphinx_end = None, additional_notebook_path = None, additional_local_path = None, copy_add_ext = None, nbformats = (‘ipynb’, ‘html’, ‘python’, ‘rst’, ‘slides’, ‘pdf’, ‘github’), layout = None, direct_call = False, additional_ut_path = None, skip_function = None, covtoken = None, stdout = None, stderr = None, use_run_cmd = False, filter_warning = None, file_filter_pep8 = None, github_owner = None, existing_history = None, coverage_root = ‘src’, fexclude = None, skip_issues = None, fLOG = None)
Processes the standard options the module pyquickhelper is able to process assuming the module which calls this function follows the same design as pyquickhelper, it will process the following options…
traceback¶
pyquickhelper.pycode.get_call_stack
()
Returns a string showing the call stack when this function is called.
unit tests¶
pyquickhelper.pycode.add_missing_development_version
(names, root, hide = False)
Looks for development version of a given module and add paths to
sys.path
after having checked they are working.
pyquickhelper.pycode.check_pep8
(folder, ignore = (‘E265’, ‘W504’), skip = None, complexity = -1, stop_after = 100, fLOG = None, pylint_ignore = (‘C0103’, ‘C1801’, ‘R1705’, ‘W0108’, ‘W0613’, ‘W0107’, ‘C0415’, ‘C0209’), recursive = True, neg_pattern = None, extended = None, max_line_length = 143, pattern = ‘.*[.]py$’, run_lint = True, verbose = False, run_cmd_filter = None)
Checks if PEP8, the function calls command pycodestyle on a specific folder.
pyquickhelper.pycode.fix_tkinter_issues_virtualenv
(exc = True, fLOG = None)
Fix an issue which happens in a virtual environment, see Fix Tcl inside a virtualenv on Windows
pyquickhelper.pycode.get_temp_folder
(thisfile, name = None, clean = True, create = True, persistent = False, path_name = ‘tpath’)
Creates and returns a local temporary folder to store files when unit testing.
pyquickhelper.pycode.is_travis_or_appveyor
(env = None)
Tells if is a travis environment or appveyor.
pyquickhelper.pycode.ExtTestCase
(self, methodName = ‘runTest’)
Overwrites unit test class with additional testing functions. Unless setUp is overwritten, warnings FutureWarning and PendingDeprecationWarning are filtered out.
virtual environments¶
pyquickhelper.pycode.check_readme_syntax
(readme, folder, version = ‘0.8’, fLOG = None)
Checks the syntax of the file
readme.rst
which describes a python project.
pyquickhelper.texthelper.compare_module_version
(num, vers)
Compares two versions.
pyquickhelper.pycode.create_virtual_env
(where, symlinks = False, system_site_packages = False, clear = True, packages = None, fLOG = None, temp_folder = None, platform = None)
Creates a virtual environment.
pyquickhelper.pycode.is_virtual_environment
()
Tells if the script is run from a virtual environment.
pyquickhelper.pycode.run_base_script
(script, fLOG = None, file = False, is_cmd = False, skip_err_if = None, argv = None, platform = None, kwargs)
Runs a script with the original intepreter even if this function is run from a virtual environment.
pyquickhelper.pycode.run_venv_script
(venv, script, fLOG = None, file = False, is_cmd = False, skip_err_if = None, platform = None, kwargs)
Runs a script on a vritual environment (the script should be simple).