U e@sdZzddlmZWnek r0dZZYnNXddlmZmZmZm Z m Z ddl m Z ddl mZddZGd d d eZdS) a nosetests setuptools command ---------------------------- The easiest way to run tests with nose is to use the `nosetests` setuptools command:: python setup.py nosetests This command has one *major* benefit over the standard `test` command: *all nose plugins are supported*. To configure the `nosetests` command, add a [nosetests] section to your setup.cfg. The [nosetests] section can contain any command line arguments that nosetests supports. The differences between issuing an option on the command line and adding it to setup.cfg are: * In setup.cfg, the -- prefix must be excluded * In setup.cfg, command line flags that take no arguments must be given an argument flag (1, T or TRUE for active, 0, F or FALSE for inactive) Here's an example [nosetests] setup.cfg section:: [nosetests] verbosity=1 detailed-errors=1 with-coverage=1 cover-package=nose debug=nose.loader pdb=1 pdb-failures=1 If you commonly run nosetests with a large number of options, using the nosetests setuptools command and configuring with setup.cfg can make running your tests much less tedious. (Note that the same options and format supported in setup.cfg are supported in all other config files, and the nosetests script will also load config files.) Another reason to run tests with the command is that the command will install packages listed in your `tests_require`, as well as doing a complete build of your package before running tests. For packages with dependencies or that build C extensions, using the setuptools command can be more convenient than building by hand and running the nosetests script. Bootstrapping ------------- If you are distributing your project and want users to be able to run tests without having to install nose themselves, add nose to the setup_requires section of your setup():: setup( # ... setup_requires=['nose>=1.0'] ) This will direct setuptools to download and activate nose during the setup process, making the ``nosetests`` command available. )CommandN)Configoption_blacklistuser_config_filesflag_bool) TestProgram)DefaultPluginManagercCsg}|jD]r}|jdddtkr&q |jddd}|jdkrJ|d}d}|jrf|jddd}||||jpvdfq |S)zAconvert a optparse option list into a distutils option tuple listrN store_true store_false=) option_list _long_optsraction _short_optsappendhelp)parserZopt_listoptZ long_nameZ short_namer;/opt/hc_python/lib/python3.8/site-packages/nose/commands.pyget_user_optionsIs  rc@sPeZdZdZeeedZeZ e e Z ddZ ddZ ddZd d Zd S) nosetestszRun unit tests using nosetests)filespluginscCsRi|_|jjD]8}|jddd}|dd}||j|<t||dqd|_dS)zWcreate the member variables, but change hyphens to underscores rr N-_)option_to_cmds_nosetests__parserrrreplacesetattrattr)selfrcmd_name option_namerrrinitialize_options`s   znosetests.initialize_optionscCsdS)znothing to do hereNr)r&rrrfinalize_optionsmsznosetests.finalize_optionsc Cs0t|jddrh|d}d|_||d}|j}|d}||_||d}d|_|n"|d|d}d|_||jjr|j |jj|jj r|j |jj |d}dd |jg}t |j D]>\}} |tkrqt||} | d k r|||d d | qt||jd d S)zhensure tests are capable of being run, then run nose.main with a reconstructed argument listZuse_2to3Fbuild_pyregg_info build_extrrz--whereNr r)argvconfig)getattr distributionget_finalized_commandZinplacerun build_libZegg_base run_commandZinstall_requiresZfetch_build_eggsZ tests_requirelistr!itemsrextendcfgToArgr#r_nosetests__config) r&r+Zbpy_cmdZ build_pathr,r-Zei_cmdr.r(r'valuerrrr3qsF          z nosetests.runcCs`g}d|}|j|}|jdkrNt|s:td||ft|r\||n|||g|S)Nz--r zInvalid value '%s' for '%s')r" get_optionrr ValueErrorrrr8)r&optnamer;r.Z long_optnamerrrrr9s   znosetests.cfgToArgN)__name__ __module__ __qualname__ descriptionrrr r:Z getParserr"r user_optionsr)r*r3r9rrrrrYs /r)__doc__ setuptoolsr ImportErrorrZ nose.configrrrrrZ nose.corerZ nose.pluginsr rrrrrs=