[Asterisk-code-review] Begin work on python3 compatability. (testsuite[master])

Corey Farrell asteriskteam at digium.com
Thu Jun 28 19:23:11 CDT 2018


Hello Kevin Harwell, Alexander Traud, Jenkins2, George Joseph, 

I'd like you to reexamine a change. Please visit

    https://gerrit.asterisk.org/8854

to look at the new patch set (#9).

Change subject: Begin work on python3 compatability.
......................................................................

Begin work on python3 compatability.

* Use explicit relative import syntax.
* Correct syntax for print and except.
* Fix incorrect usage of IOError in astcdr.py - IOError is not a tuple.
* Use items, values instead of iteritems, itervalues.
* Use OrderedDict from collections if available (python 2.7+).
* Do not unpack tuples from argument list, save tuple to variable then
  unpack within code.
* Use exception handler to import Python3 version of urlencode if the
  Python2 version fails to import.
* Remove unused import unittest from opensslversion.
* Move executable tests to separate files to resolve issues with
  relative imports:
  - buildoptions
  - cdr
  - cel
  - channel_test_condition
  - config
  - lock_test_condition
  - sip_dialog_test_condition (disabled)
  - sippversion
* Modify utils_socket test to use new harness_shared module.
* Remove unused executable flag and shebang from phones.py.
* Update self_test script to run tests from new location.
* Remove ability to use config.py to display a config file.
* Allow PYTHON environmental variable to tell run-local to use a
  specific python binary.
* Execute test_runner.py using python -m syntax.  This avoids conflicts
  between needing to use relative imports for modules but not being
  allowed to use them in executable scripts.
* Encode self.realbase for use with md5 function.
* Remove executable flag and shebang from test_runner.py.  Remove
  redundant appending of sys.path.
* Modify output for running test and status to print the name of the
  test instead of the command used to run the test.
* Use key= sorter argument to compare sizes of tmp filesystems.  This
  may cause us to use /var/tmp instead of /tmp even if /var/tmp has only
  a few kilobytes more space but python3 does not support cmp= argument
  to sorter.
* Decode binary to utf-8
  - CLI output
  - runtest.py subprocess output
  - XML printed to stdout
  - SyncAMI data
  - SIPp runtime and version output
* Update test_runner.load_and_parse_module to check for the module in
  lib/python/asterisk, make required adjustments if found.
* Update __strip_illegal_xml_chars to work with unicode version of
  str.translate which does not support second argument.
* Update import statements from all *.py modules within tests/ to use
  absolute names for asterisk modules.  This is required for python2 to
  continue functioning with the new way that test_runner must be executed.
  No attempt has been made to fix python3 compatibility issues in these
  modules.

Some tests may pass using python3.  Doing so requires using an updated
starpy and no python sources within tests/ have been updated.  Unit
tests from lib/python can be run against python2 and python3 using
./self_test.

The goal of this is for all tests to continue functioning using python2.
Some tests may work under python3 but individual tests will need to be
addressed separately.  For tests which do not contain a run-test script
the version of python used to execute ./runtests.py will be used:
./runtests.py -t tests/manager/originate
python2 ./runtests.py -t tests/manager/originate
python3 ./runtests.py -t tests/manager/originate

These commands will be python, python2 and python3 respectively.  The
first example where no interpreter is specified uses the shebang from
./runtests.py.  The interpreter used by ./run-local can be controlled
by setting PYTHON environmental variable:
PYTHON=python3 ./run-local run -t tests/manager/originate

Change-Id: If76c2d3e11e4ab4552d0df7841287c8bb2de7918
---
M lib/python/asterisk/ami.py
M lib/python/asterisk/apptest.py
M lib/python/asterisk/ari.py
M lib/python/asterisk/astconfigparser.py
M lib/python/asterisk/astcsv.py
M lib/python/asterisk/astdicts.py
M lib/python/asterisk/asterisk.py
M lib/python/asterisk/bridge_test_case.py
M lib/python/asterisk/buildoptions.py
M lib/python/asterisk/cdr.py
M lib/python/asterisk/cel.py
M lib/python/asterisk/channel_test_condition.py
M lib/python/asterisk/confbridge.py
M lib/python/asterisk/config.py
M lib/python/asterisk/fd_test_condition.py
M lib/python/asterisk/lock_test_condition.py
M lib/python/asterisk/matcher.py
M lib/python/asterisk/matcher_listener.py
M lib/python/asterisk/opensslversion.py
M lib/python/asterisk/originate.py
M lib/python/asterisk/pcap.py
M lib/python/asterisk/phones.py
M lib/python/asterisk/pjsua_mod.py
M lib/python/asterisk/pluggable_modules.py
M lib/python/asterisk/pluggable_registry.py
M lib/python/asterisk/realtime_converter.py
M lib/python/asterisk/realtime_odbc_module.py
M lib/python/asterisk/realtime_test_module.py
A lib/python/asterisk/self_test/harness_shared.py
A lib/python/asterisk/self_test/locks-backtrace.txt
A lib/python/asterisk/self_test/locks-fail.txt
A lib/python/asterisk/self_test/locks-large-multiple-object.txt
A lib/python/asterisk/self_test/locks-multiple-objects-no-backtrace.txt
A lib/python/asterisk/self_test/locks-pass.txt
A lib/python/asterisk/self_test/locks-single-object-no-held-info.txt
A lib/python/asterisk/self_test/locks-single-object.txt
A lib/python/asterisk/self_test/test_buildoptions.py
A lib/python/asterisk/self_test/test_cdr.py
A lib/python/asterisk/self_test/test_cel.py
A lib/python/asterisk/self_test/test_channel_test_condition.py
A lib/python/asterisk/self_test/test_config.py
A lib/python/asterisk/self_test/test_lock_test_condition.py
R lib/python/asterisk/self_test/test_matcher.py
A lib/python/asterisk/self_test/test_sip_dialog_test_condition.py.txt
A lib/python/asterisk/self_test/test_sippversion.py
M lib/python/asterisk/self_test/test_utils_socket.py
M lib/python/asterisk/sip_channel_test_condition.py
M lib/python/asterisk/sip_dialog_test_condition.py
M lib/python/asterisk/sipp.py
M lib/python/asterisk/sippversion.py
M lib/python/asterisk/syncami.py
M lib/python/asterisk/test_case.py
M lib/python/asterisk/test_conditions.py
M lib/python/asterisk/test_config.py
M lib/python/asterisk/test_runner.py
M lib/python/asterisk/test_suite_utils.py
M lib/python/asterisk/thread_test_condition.py
M lib/python/asterisk/voicemail.py
M lib/python/rlmi.py
M lib/python/sip_message.py
M run-local
M runtests.py
M self_test
M tests/cdr/cdr-tests.py
M tests/cdr/sqlite3/cdr_sqlite3.py
M tests/channels/SIP/tcpauthlimit/sipp_scenario.py
M tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py
M tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py
M tests/channels/pjsip/subscriptions/presence/verify_bodies/presence.py
M tests/channels/pjsip/subscriptions/rls/rls_test.py
M tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py
M tests/codecs/audio_analyzer.py
M tests/codecs/rtp_analyzer.py
M tests/hep/hep_capture_node.py
M tests/manager/config/ManagerConfigTest.py
M tests/manager/device_state_changed/ami_device_state.py
M tests/manager/device_state_list/ami_device_state_list.py
M tests/manager/exten_state_list/ami_exten_state_list.py
M tests/manager/presence_state_changed/ami_presence_state.py
M tests/manager/presence_state_list/ami_presence_state_list.py
M tests/pbx/manager_extensions/ami_extension_control.py
M tests/rest_api/external_interaction/attended_transfer/attended_transfer.py
M tests/rest_api/external_interaction/blind_transfer/call_transfer.py
M tests/rest_api/message/message_modules.py
M usage.py
85 files changed, 1,910 insertions(+), 1,841 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/54/8854/9
-- 
To view, visit https://gerrit.asterisk.org/8854
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If76c2d3e11e4ab4552d0df7841287c8bb2de7918
Gerrit-Change-Number: 8854
Gerrit-PatchSet: 9
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180628/eeba314b/attachment-0001.html>


More information about the asterisk-code-review mailing list