Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAIL: stestr.tests.test_return_codes.TestReturnCodesToxIni.test_no_repo_dir on python 3.12.2 #362

Open
masayukig opened this issue Apr 4, 2024 · 2 comments
Labels

Comments

@masayukig
Copy link
Collaborator

masayukig commented Apr 4, 2024

Issue description

When I run stestr tests, these tests fail everytime.

$ stestr failing
======================================================================
FAIL: stestr.tests.test_return_codes.TestReturnCodesToxIni.test_no_repo_dir
tags: worker-5
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/migawa/git/stestr/stestr/tests/test_return_codes.py", line 233, in test_no_repo_dir
    self.assertRunExit("stestr run passing", 0)
  File "/home/migawa/git/stestr/stestr/tests/test_return_codes.py", line 99, in assertRunExit
    self.assertEqual(
  File "/home/migawa/.local/lib/python3.12/site-packages/testtools/testcase.py", line 395, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/home/migawa/.local/lib/python3.12/site-packages/testtools/testcase.py", line 482, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: 1 != 0: Stdout: b''; Stderr: b'module \'configparser\' has no attribute \'SafeConfigParser\'\nTraceback (most recent call last):\n  File "/home/migawa/git/stestr/stestr/repository/file.py", line 60, in open\n    stream = open(os.path.join(base, "format"))\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory: \'/tmp/stestr-unit8d7f9bd_/.stestr/format\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "/home/migawa/git/stestr/stestr/commands/run.py", line 470, in run_command\n    repo = util.get_repo_open(repo_url=repo_url)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/home/migawa/git/stestr/stestr/repository/util.py", line 45, in get_repo_open\n    return repo_module.RepositoryFactory().open(repo_url)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/home/migawa/git/stestr/stestr/repository/file.py", line 63, in open\n    raise repository.RepositoryNotFound(url)\nstestr.repository.abstract.RepositoryNotFound: No repository found in /tmp/stestr-unit8d7f9bd_. Create one by running "stestr init".\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "/home/migawa/.local/lib/python3.12/site-packages/cliff/app.py", line 410, in run_subcommand\n    result = cmd.run(parsed_args)\n             ^^^^^^^^^^^^^^^^^^^^\n  File "/home/migawa/.local/lib/python3.12/site-packages/cliff/command.py", line 181, in run\n    return_code = self.take_action(parsed_args) or 0\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/home/migawa/git/stestr/stestr/commands/run.py", line 309, in take_action\n    result = run_command(\n             ^^^^^^^^^^^^\n  File "/home/migawa/git/stestr/stestr/commands/run.py", line 476, in run_command\n    tox_conf = configparser.SafeConfigParser()\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: module \'configparser\' has no attribute \'SafeConfigParser\'. Did you mean: \'RawConfigParser\'?\n'
======================================================================
FAIL: stestr.tests.test_return_codes.TestReturnCodesToxIni.test_empty_repo_dir
tags: worker-2
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/migawa/git/stestr/stestr/tests/test_return_codes.py", line 240, in test_empty_repo_dir
    self.assertRunExit("stestr run passing", 0)
  File "/home/migawa/git/stestr/stestr/tests/test_return_codes.py", line 99, in assertRunExit
    self.assertEqual(
  File "/home/migawa/.local/lib/python3.12/site-packages/testtools/testcase.py", line 395, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/home/migawa/.local/lib/python3.12/site-packages/testtools/testcase.py", line 482, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: 1 != 0: Stdout: b''; Stderr: b'module \'configparser\' has no attribute \'SafeConfigParser\'\nTraceback (most recent call last):\n  File "/home/migawa/git/stestr/stestr/repository/file.py", line 60, in open\n    stream = open(os.path.join(base, "format"))\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory: \'/tmp/stestr-unitldbt_6m6/.stestr/format\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "/home/migawa/git/stestr/stestr/commands/run.py", line 470, in run_command\n    repo = util.get_repo_open(repo_url=repo_url)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/home/migawa/git/stestr/stestr/repository/util.py", line 45, in get_repo_open\n    return repo_module.RepositoryFactory().open(repo_url)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/home/migawa/git/stestr/stestr/repository/file.py", line 63, in open\n    raise repository.RepositoryNotFound(url)\nstestr.repository.abstract.RepositoryNotFound: No repository found in /tmp/stestr-unitldbt_6m6. Create one by running "stestr init".\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "/home/migawa/.local/lib/python3.12/site-packages/cliff/app.py", line 410, in run_subcommand\n    result = cmd.run(parsed_args)\n             ^^^^^^^^^^^^^^^^^^^^\n  File "/home/migawa/.local/lib/python3.12/site-packages/cliff/command.py", line 181, in run\n    return_code = self.take_action(parsed_args) or 0\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/home/migawa/git/stestr/stestr/commands/run.py", line 309, in take_action\n    result = run_command(\n             ^^^^^^^^^^^^\n  File "/home/migawa/git/stestr/stestr/commands/run.py", line 476, in run_command\n    tox_conf = configparser.SafeConfigParser()\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: module \'configparser\' has no attribute \'SafeConfigParser\'. Did you mean: \'RawConfigParser\'?\n'
Ran 2 tests in 6.935s
FAILED (id=5, failures=2)

Expected behavior and actual behavior
Expected: No failures
Actual:

Steps to reproduce the problem
stestr run on the environment like below.

Specifications like the version of the project, operating system, or hardware

System information

  • OS: Fedora 39
  • stestr version (stestr --version): stestr 4.0.1.dev15
  • Python release (python --version): Python 3.12.2
  • pip packages (pip freeze):
$ pip freeze
alabaster==0.7.16
attrs==23.2.0
autopage==0.5.2
Babel==2.14.0
black==22.12.0
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
cliff==4.6.0
cmd2==2.4.3
coverage==7.4.4
ddt==1.7.2
doc8==1.1.1
docutils==0.20.1
fixtures==4.1.0
flake8==3.8.4
hacking==3.1.0
idna==3.6
imagesize==1.4.1
iso8601==2.1.0
Jinja2==3.1.3
MarkupSafe==2.1.5
mccabe==0.6.1
mypy-extensions==1.0.0
packaging==24.0
pathspec==0.12.1
pbr==6.0.0
platformdirs==4.2.0
prettytable==3.10.0
pycodestyle==2.6.0
pyflakes==2.2.0
Pygments==2.17.2
pyperclip==1.8.2
python-subunit==1.4.4
PyYAML==6.0.1
requests==2.31.0
restructuredtext_lint==1.4.0
setuptools==69.2.0
snowballstemmer==2.2.0
Sphinx==7.2.6
sphinxcontrib-applehelp==1.0.8
sphinxcontrib-devhelp==1.0.6
sphinxcontrib-htmlhelp==2.0.5
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.7
sphinxcontrib-serializinghtml==1.1.10
stevedore==5.2.0
testtools==2.7.1
urllib3==2.2.1
voluptuous==0.14.2
wcwidth==0.2.13

Additional information
I'm facing two failures on stestr.tests.test_return_codes.TestReturnCodesToxIni.test_no_repo_dir and stestr.tests.test_return_codes.TestReturnCodesToxIni.test_empty_repo_dir. And it seems that the same error happens in both tests.

This issue doesn't happen on python 3.11.8 on my environment(Fedora39) somehow.

$ python --version
Python 3.11.8
$ stestr --version
stestr 4.0.1.dev14
$ stestr failing
PASSED (id=13)
@masayukig masayukig added the bug label Apr 4, 2024
@masayukig
Copy link
Collaborator Author

Looking at the code, the tests fail when running stestr run passing after shutil.rmtree(stestr_repodir). I'm not sure why this failure happens only on python 3.12 yet..

https://github.com/mtreinish/stestr/blob/main/stestr/tests/test_return_codes.py#L229-L240

    def test_no_repo_dir(self):
        stestr_repo_dir = os.path.join(self.directory, ".stestr")
        shutil.rmtree(stestr_repo_dir, ignore_errors=True)
        # We can use stestr run even if there's no repo directory.
        self.assertRunExit("stestr run passing", 0)

    def test_empty_repo_dir(self):
        stestr_repo_dir = os.path.join(self.directory, ".stestr")
        shutil.rmtree(stestr_repo_dir, ignore_errors=True)
        os.mkdir(stestr_repo_dir)
        # We can initialize an empty repo directory.
        self.assertRunExit("stestr run passing", 0)

@jelly
Copy link

jelly commented Apr 9, 2024

On Arch Linux with 3.12 we get:

stestr.tests.test_return_codes.TestReturnCodesToxIni.test_history_empty
-----------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/build/python-stestr/src/stestr-4.1.0/stestr/tests/test_return_codes.py", line 336, in test_history_empty
    self.assertEqual("", "\n".join([x.rstrip() for x in table.split("\n")]).strip())

      File "/usr/lib/python3.12/site-packages/testtools/testcase.py", line 395, in assertEqual
    self.assertThat(observed, matcher, message)

      File "/usr/lib/python3.12/site-packages/testtools/testcase.py", line 482, in assertThat
    raise mismatch_error

    testtools.matchers._impl.MismatchError: '' != '"Run ID","Passed","Runtime","Date"'


stestr.tests.test_return_codes.TestReturnCodesToxIni.test_history_list
----------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/build/python-stestr/src/stestr-4.1.0/stestr/tests/test_return_codes.py", line 321, in test_history_list
    self.assertIn("| 0      | True   |", table.split("\n")[3].rstrip())

      File "/usr/lib/python3.12/site-packages/testtools/testcase.py", line 401, in assertIn
    self.assertThat(haystack, Contains(needle), message)

      File "/usr/lib/python3.12/site-packages/testtools/testcase.py", line 482, in assertThat
    raise mismatch_error

    testtools.matchers._impl.MismatchError: '| 0      | True   |' not in '"2",True,"0.000670s","2024-04-09 18:35:50.974916+00:00"'

And:

stestr.tests.test_return_codes.TestReturnCodes.test_history_empty
-----------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/build/python-stestr/src/stestr-4.1.0/stestr/tests/test_return_codes.py", line 336, in test_history_empty
    self.assertEqual("", "\n".join([x.rstrip() for x in table.split("\n")]).strip())

      File "/usr/lib/python3.12/site-packages/testtools/testcase.py", line 395, in assertEqual
    self.assertThat(observed, matcher, message)

      File "/usr/lib/python3.12/site-packages/testtools/testcase.py", line 482, in assertThat
    raise mismatch_error

    testtools.matchers._impl.MismatchError: '' != '"Run ID","Passed","Runtime","Date"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants