Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#13262 closed defect (fixed)

test command has been deprecated since setuptools 41.5.0

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.0.20
Component: general Version: 1.0.19
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Invoke directly unittest.main() instead of setup.py test deprecated.

Description

1.0-stable and 1.2-stable use test command of setuptools.

%.py : status
        python setup.py -q test -s $(subst /,.,$(@:.py=)).suite $(testopts)

ifdef test
all: status
        python setup.py -q test -s $(subst /,.,$(test:.py=)).suite $(testopts)
else
all: help
endif

The test command has been deprecated since setuptools 41.5.0.

python setup.py -q test -s trac.versioncontrol.tests.functional.suite
WARNING: Testing via this command is deprecated and will be removed in a future version.
 Users looking for a generic test entry point independent of test runner are encouraged
 to use tox.

See also:

Attachments (0)

Change History (6)

comment:1 by Ryan J Ollos, 5 years ago

Not sure if we can use unittest module like in r17088:

Changed in version 2.7: In earlier versions it was only possible to run individual test methods and not modules or classes.

comment:2 by Jun Omae, 5 years ago

I've tried python -m unittest <test-suite> but ValueError is raised due to not a test with Python 2.5 and 2.6.

$ PYTHONPATH=. ~/venv/py25/bin/python -m unittest trac.tests.core.suite
Traceback (most recent call last):
  File "/usr/lib/python2.5/runpy.py", line 95, in run_module
    filename, loader, alter_sys)
  File "/usr/lib/python2.5/runpy.py", line 52, in _run_module_code
    mod_name, mod_fname, mod_loader)
  File "/usr/lib/python2.5/runpy.py", line 32, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.5/unittest.py", line 816, in <module>
    main(module=None)
  File "/usr/lib/python2.5/unittest.py", line 767, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.5/unittest.py", line 794, in parseArgs
    self.createTests()
  File "/usr/lib/python2.5/unittest.py", line 800, in createTests
    self.module)
  File "/usr/lib/python2.5/unittest.py", line 565, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.5/unittest.py", line 556, in loadTestsFromName
    "calling %s returned %s, not a test" % (obj,test)
ValueError: calling <function suite at 0x33f2848> returned <unittest.TestSuite tests=[<unittest.TestSuite tests=[<trac.tests.core.TracErrorTestCase testMethod=test_init>, <trac.tests.core.TracErrorTestCase testMethod=test_unicode>]>, <unittest.TestSuite tests=[<trac.tests.core.ComponentTestCase testMethod=test_abstract_component_not_registered>, <trac.tests.core.ComponentTestCase testMethod=test_attribute_access>, <trac.tests.core.ComponentTestCase testMethod=test_base_class_not_registered>, <trac.tests.core.ComponentTestCase testMethod=test_component_identity>, <trac.tests.core.ComponentTestCase testMethod=test_component_initializer>, <trac.tests.core.ComponentTestCase testMethod=test_component_manager_component>, <trac.tests.core.ComponentTestCase testMethod=test_component_manager_component_isolation>, <trac.tests.core.ComponentTestCase testMethod=test_component_registration>, <trac.tests.core.ComponentTestCase testMethod=test_extension_point_with_no_extension>, <trac.tests.core.ComponentTestCase testMethod=test_extension_point_with_one_extension>, <trac.tests.core.ComponentTestCase testMethod=test_extension_point_with_two_extensions>, <trac.tests.core.ComponentTestCase testMethod=test_implements_called_outside_classdef>, <trac.tests.core.ComponentTestCase testMethod=test_implements_multiple>, <trac.tests.core.ComponentTestCase testMethod=test_inherited_component_initializer>, <trac.tests.core.ComponentTestCase testMethod=test_inherited_extension_point>, <trac.tests.core.ComponentTestCase testMethod=test_inherited_implements>, <trac.tests.core.ComponentTestCase testMethod=test_inherited_implements_multilevel>, <trac.tests.core.ComponentTestCase testMethod=test_instantiation_doesnt_enable>, <trac.tests.core.ComponentTestCase testMethod=test_invalid_argument_raises>, <trac.tests.core.ComponentTestCase testMethod=test_nonconforming_extender>, <trac.tests.core.ComponentTestCase testMethod=test_unregistered_component>]>]>, not a test

Another idea, we could invoke directly unitest.main via -c option with Python 2.5 and 2.6.

  • Makefile

    diff --git a/Makefile b/Makefile
    index 55d4be4c2..b5c9d83e7 100644
    a b export HELP_CFG  
    6161
    6262.PHONY: all help help-all status clean clean-bytecode clean-mo
    6363
     64define unittest-main
     65    python -c 'import unittest; from $1 import suite; unittest.main(defaultTest="suite")' $(testopts)
     66endef
     67
    6468%.py : status
    65         python setup.py -q test -s $(subst /,.,$(@:.py=)).suite $(testopts)
     69        $(call unittest-main,$(subst /,.,$(@:.py=)))
    6670
    6771ifdef test
    6872all: status
    69         python setup.py -q test -s $(subst /,.,$(test:.py=)).suite $(testopts)
     73        $(call unittest-main,$(subst /,.,$(test:.py=)))
    7074else
    7175all: help
    7276endif
$ make python=25 trac/tests/core.py

Python: /home/jun66j5/venv/py25/bin/python

  Package        Version
  ---------------------------------------------------------
  Python       : 2.5.6 (r256:88840, Oct 21 2014, 22:49:55)
               : [GCC 4.8.2]
  Setuptools   : 0.6c11
  Pip          : 1.3.1
  Wheel        : not installed
  Genshi       : 0.7 (with speedups)
  Babel        : 0.9.6
  sqlite3      : 2.3.2 (3.11.0)
  PySqlite     : 2.7.0 (3.11.0)
  MySQLdb      : 1.2.5
  Psycopg2     : 2.5.2 (dt dec pq3 ext)
  SVN bindings : 1.9.3 (r1718519)
  Mercurial    : 3.4.2
  Pygments     : 1.6
  Textile      : not installed
  Pytz         : 2018.9
  ConfigObj    : 4.7.2
  Docutils     : 0.14
  Twill        : 0.9
  LXML         : 3.3.6
  coverage     : 3.7.1
  figleaf      : not installed

Variables:
  PATH=/home/jun66j5/venv/py25/bin:/home/jun66j5/bin:/home/jun66j5/.gem/ruby/2.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
  PYTHONPATH=.
  TRAC_TEST_DB_URI=
  server-options= -p 3000 -a '*,/home/jun66j5/src/trac-htdigest.txt,auth'  -e

External dependencies:
  Git version: git version 2.26.0
  Subversion version: 1.9.3

python -c 'import unittest; from trac.tests.core import suite; unittest.main(defaultTest="suite")'
.......................
----------------------------------------------------------------------
Ran 23 tests in 0.002s

OK

$ make python=25 testopts=-v trac/tests/core.py

Python: /home/jun66j5/venv/py25/bin/python

  Package        Version
  ---------------------------------------------------------
  Python       : 2.5.6 (r256:88840, Oct 21 2014, 22:49:55)
               : [GCC 4.8.2]
  Setuptools   : 0.6c11
  Pip          : 1.3.1
  Wheel        : not installed
  Genshi       : 0.7 (with speedups)
  Babel        : 0.9.6
  sqlite3      : 2.3.2 (3.11.0)
  PySqlite     : 2.7.0 (3.11.0)
  MySQLdb      : 1.2.5
  Psycopg2     : 2.5.2 (dt dec pq3 ext)
  SVN bindings : 1.9.3 (r1718519)
  Mercurial    : 3.4.2
  Pygments     : 1.6
  Textile      : not installed
  Pytz         : 2018.9
  ConfigObj    : 4.7.2
  Docutils     : 0.14
  Twill        : 0.9
  LXML         : 3.3.6
  coverage     : 3.7.1
  figleaf      : not installed

Variables:
  PATH=/home/jun66j5/venv/py25/bin:/home/jun66j5/bin:/home/jun66j5/.gem/ruby/2.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
  PYTHONPATH=.
  TRAC_TEST_DB_URI=
  server-options= -p 3000 -a '*,/home/jun66j5/src/trac-htdigest.txt,auth'  -e

External dependencies:
  Git version: git version 2.26.0
  Subversion version: 1.9.3

python -c 'import unittest; from trac.tests.core import suite; unittest.main(defaultTest="suite")' -v
test_init (trac.tests.core.TracErrorTestCase) ... ok
test_unicode (trac.tests.core.TracErrorTestCase) ... ok
test_abstract_component_not_registered (trac.tests.core.ComponentTestCase) ... ok
test_attribute_access (trac.tests.core.ComponentTestCase) ... ok
test_base_class_not_registered (trac.tests.core.ComponentTestCase) ... ok
test_component_identity (trac.tests.core.ComponentTestCase) ... ok
test_component_initializer (trac.tests.core.ComponentTestCase) ... ok
test_component_manager_component (trac.tests.core.ComponentTestCase) ... ok
test_component_manager_component_isolation (trac.tests.core.ComponentTestCase) ... ok
test_component_registration (trac.tests.core.ComponentTestCase) ... ok
test_extension_point_with_no_extension (trac.tests.core.ComponentTestCase) ... ok
test_extension_point_with_one_extension (trac.tests.core.ComponentTestCase) ... ok
test_extension_point_with_two_extensions (trac.tests.core.ComponentTestCase) ... ok
test_implements_called_outside_classdef (trac.tests.core.ComponentTestCase) ... ok
test_implements_multiple (trac.tests.core.ComponentTestCase) ... ok
test_inherited_component_initializer (trac.tests.core.ComponentTestCase) ... ok
test_inherited_extension_point (trac.tests.core.ComponentTestCase) ... ok
test_inherited_implements (trac.tests.core.ComponentTestCase) ... ok
test_inherited_implements_multilevel (trac.tests.core.ComponentTestCase) ... ok
test_instantiation_doesnt_enable (trac.tests.core.ComponentTestCase) ... ok
test_invalid_argument_raises (trac.tests.core.ComponentTestCase) ... ok
test_nonconforming_extender (trac.tests.core.ComponentTestCase) ... ok
test_unregistered_component (trac.tests.core.ComponentTestCase) ... ok

----------------------------------------------------------------------
Ran 23 tests in 0.006s

OK

comment:3 by Ryan J Ollos, 5 years ago

That change looks good.

comment:4 by Jun Omae, 5 years ago

Owner: set to Jun Omae
Status: newassigned

Thanks for the reviewing. I'll push the changes.

comment:5 by Jun Omae, 5 years ago

Milestone: next-stable-1.2.x1.0.20
Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [17263] (1.0-stable) and merged in [17264] (1.2-stable).

comment:6 by Ryan J Ollos, 4 years ago

Internal Changes: modified (diff)
Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.