Skip to content

[2.7] Fix python2 -m test --list-cases test_multibytecodec_support test_robotparser #74944

Closed

Description

@vstinner
BPO 30759
Nosy @vstinner, @zware, @serhiy-storchaka, @emilyemorehouse
PRs
  • [2.7] bpo-30759: Fix test_multibytecodec_support #2545
  • [2.7] bpo-30759: Copy test_robotparser from master #2546
  • [2.7] bpo-30759: Rename test_ file that is really a support file to remove test_prefix. #2548
  • [2.7] bpo-30759: regrtest: list_cases() now unload modules #2582
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-07-05.08:54:15.200>
    created_at = <Date 2017-06-26.09:44:05.443>
    labels = ['tests']
    title = '[2.7] Fix python2 -m test --list-cases test_multibytecodec_support test_robotparser'
    updated_at = <Date 2017-07-05.08:54:15.199>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2017-07-05.08:54:15.199>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-07-05.08:54:15.200>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2017-06-26.09:44:05.443>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30759
    keywords = []
    message_count = 8.0
    messages = ['296862', '296996', '297008', '297602', '297713', '297715', '297717', '297718']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'zach.ware', 'serhiy.storchaka', 'emilyemorehouse']
    pr_nums = ['2545', '2546', '2548', '2582']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue30759'
    versions = ['Python 2.7']

    Activity

    1. vstinner commented on Jun 26, 2017

      @vstinner
      MemberAuthor

      On Python 2.7, listing *all* test cases with "./python -m test --list-cases" fails on the following test files:

      • test_multibytecodec_support
      • test_robotparser

      regrtest of Python 2.7 uses the test_main() function of each test file, if the function is defined. Whereas --list-cases is more written as a raw discovery function listing all cases which inherit from unittest.TestCase. These 3 files have base test cases which are "abstract" or configured below.

      Options:

      • Modify --list-cases to tolerate failures and report them at exit
      • Modify these 2 tests to make them more "test discovery"-friendly
      • Use test_main() function if available but modify its behaviour to only list test cases, instead of running them

      I would prefer to limit changes in Python 2.7 branch, so IMHO the second option is the best: modify the 2 tests.

      haypo@selma$ ./python -m test --list-cases test_multibytecodec_support
      Traceback (most recent call last):
        ...
        File "/home/haypo/prog/python/2.7/Lib/test/test_multibytecodec_support.py", line 268, in __init__
          self.open_mapping_file().close() # test it to report the error early
        File "/home/haypo/prog/python/2.7/Lib/test/test_multibytecodec_support.py", line 273, in open_mapping_file
          return test_support.open_urlresource(self.mapfileurl)
      AttributeError: 'TestBase_Mapping' object has no attribute 'mapfileurl'
      
      
      haypo@selma$ ./python -m test --list-cases test_robotparser
      Traceback (most recent call last):
        ...
        File "/home/haypo/prog/python/2.7/Lib/test/regrtest.py", line 1511, in list_cases
          suite = unittest.defaultTestLoader.loadTestsFromName(abstest)
        File "/home/haypo/prog/python/2.7/Lib/unittest/loader.py", line 103, in loadTestsFromName
          return self.loadTestsFromModule(obj)
        File "/home/haypo/prog/python/2.7/Lib/unittest/loader.py", line 65, in loadTestsFromModule
          tests.append(self.loadTestsFromTestCase(obj))
        File "/home/haypo/prog/python/2.7/Lib/unittest/loader.py", line 56, in loadTestsFromTestCase
          loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
      TypeError: __init__() takes exactly 6 arguments (2 given)
    2. serhiy-storchaka commented on Jun 27, 2017

      @serhiy-storchaka
      Member

      I have doubts that only 2 tests need to be modified. Making tests discoverable in Python 3 was a long work made by many developers in many issues, and it still is not finished. Some of changes were not trivial and needed rewriting the architecture of the tests.

      Yet one option is forgot about 2.7.

    3. vstinner commented on Jun 27, 2017

      @vstinner
      MemberAuthor

      Well, this issue is not about discovering all test methods, but just to not
      fail with an error on: ./python -m test --list-cases

    4. vstinner commented on Jul 3, 2017

      @vstinner
      MemberAuthor

      For Lib/test/test_robotparser.py: with the current design of the test file, it's not easy to fix. I tried a different approach: copy the file from the match branch and adapt it for Python 2.7.

      See #2546

    5. vstinner commented on Jul 5, 2017

      @vstinner
      MemberAuthor

      New changeset 668489a by Victor Stinner in branch '2.7':
      bpo-30759: Copy test_robotparser from master (bpo-2546)
      668489a

    6. vstinner commented on Jul 5, 2017

      @vstinner
      MemberAuthor

      Hum, it still doesn't work. With my latest PR, "./python -m test --list-cases" now work on all tests of Python 2.7:

      #2582

    7. vstinner commented on Jul 5, 2017

      @vstinner
      MemberAuthor

      New changeset 8767de2 by Victor Stinner in branch '2.7':
      bpo-30759: regrtest: list_cases() now unload modules (bpo-2582)
      8767de2

    8. vstinner commented on Jul 5, 2017

      @vstinner
      MemberAuthor

      Ok, this one is now fixed ;-)

    9. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      testsTests in the Lib/test dir

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions