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

Test Case Fails Due to Newline Counting Assertion on Python 3.8.3 #218

Open
gkapfham opened this issue Jun 27, 2020 · 0 comments
Open

Test Case Fails Due to Newline Counting Assertion on Python 3.8.3 #218

gkapfham opened this issue Jun 27, 2020 · 0 comments

Comments

@gkapfham
Copy link
Collaborator

Describe the bug

――――――――――――――――――― test_no_arguments_incorrect_system_exit ―――――――――――――――――――

capsys = <_pytest.capture.CaptureFixture object at 0x7fb891719e20>

    def test_no_arguments_incorrect_system_exit(capsys):
        """No command-line arguments causes SystemExit crash of argparse with error output."""
        with pytest.raises(SystemExit):
            _ = check_CountFileLines.parse([])
        captured = capsys.readouterr()
        # there is no standard output
        counted_newlines = captured.out.count("\n")
        assert counted_newlines == 0
        # standard error has two lines from pytest
        assert "usage:" in captured.err
        counted_newlines = captured.err.count("\n")
>       assert counted_newlines == 2
E       assert 3 == 2

tests/checks/test_check_CountFileLines.py:26: AssertionError

 tests/checks/test_check_CountFileLines.py ⨯                     68% ██████▊
=========================== short test summary info ===========================
FAILED tests/checks/test_check_CountFileLines.py::test_no_arguments_incorrect_system_exit
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!

To Reproduce

Steps to reproduce the behavior:

  1. Run the test suite with pipenv run test on Python 3.8.3
  2. Observe that the test case fails
  3. Note that the test case passes when using older versions of Python

Expected behavior

The test suite should pass.

Environment

  • Ubuntu Linux 16.04
  • Python 3.8.3 installed through Pyenv

Additional context

If you run the test suite in the Python 3.8.3 interpreter through the Invoke-based approach with the following command:

invoke -c scripts/tasks test --pyenv 3.7.7 --pyenv 3.8.3

then the test suite passes correctly! Here is the evidence

$ invoke -c scripts/tasks test --pyenv 3.7.7 --pyenv 3.8.3
Python version: 3.7.7
Virtualenv already exists!
Removing existing virtualenv…
Creating a virtualenv for this project…
Pipfile: /home/gkapfham/working/source/gatorgrader/Pipfile
Using /home/gkapfham/.pyenv/versions/3.7.7/bin/python (3.7.7) to create virtualenv…
⠴ Creating virtual environment...created virtual environment CPython3.7.7.final.0-64 in 245ms
  creator CPython3Posix(dest=/home/gkapfham/.local/share/virtualenvs/gatorgrader-EhHiZ3CP-/home/gkapfham/.pyenv/shims/python, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/gkapfham/.local/share/virtualenv)
    added seed packages: pip==20.1.1, setuptools==47.3.1, wheel==0.34.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment!
Virtualenv location: /home/gkapfham/.local/share/virtualenvs/gatorgrader-EhHiZ3CP-/home/gkapfham/.pyenv/shims/python
Installing dependencies from Pipfile…
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
Python 3.7.7
============================= test session starts ==============================
platform linux -- Python 3.7.7, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /home/gkapfham/working/source/gatorgrader, inifile: pytest.ini
plugins: sugar-0.9.3, cov-2.10.0
collected 925 items

tests/test_arguments.py ..........
tests/test_checkers.py .........................
tests/test_comments.py ........................................................................................................................................................
tests/test_constants.py .....................................
tests/test_display.py ......
tests/test_files.py ....................
tests/test_fragments.py ..............................................................................................................................................................................
tests/test_invoke.py ....................................
tests/test_leave.py ..........
tests/test_markdown.py ...................
tests/test_orchestrate.py ........................
tests/test_report.py ......
tests/test_repository.py ...........
tests/test_run.py ......
tests/test_util.py .............................................
tests/checks/test_check_ConfirmFileExists.py ...........
tests/checks/test_check_CountCommandOutput.py .....................
tests/checks/test_check_CountCommits.py ...........
tests/checks/test_check_CountFileLines.py ....................
tests/checks/test_check_CountFileParagraphs.py ....................
tests/checks/test_check_CountFileWords.py ....................
tests/checks/test_check_CountMarkdownTags.py ..........................
tests/checks/test_check_CountMultipleLineComments.py .................................
tests/checks/test_check_CountParagraphWords.py ....................
tests/checks/test_check_CountSingleLineComments.py .................................
tests/checks/test_check_ExecuteCommand.py ..........
tests/checks/test_check_ListChecks.py ....................
tests/checks/test_check_MatchCommandFragment.py ......................
tests/checks/test_check_MatchCommandRegex.py ................................
tests/checks/test_check_MatchFileFragment.py ......................
tests/checks/test_check_MatchFileRegex.py .......................

============================= 925 passed in 7.49s ==============================
Python version: 3.8.3
Virtualenv already exists!
Removing existing virtualenv…
Creating a virtualenv for this project…
Pipfile: /home/gkapfham/working/source/gatorgrader/Pipfile
Using /home/gkapfham/.pyenv/versions/3.8.3/bin/python (3.8.3) to create virtualenv…
⠴ Creating virtual environment...created virtual environment CPython3.8.3.final.0-64 in 234ms
  creator CPython3Posix(dest=/home/gkapfham/.local/share/virtualenvs/gatorgrader-EhHiZ3CP-/home/gkapfham/.pyenv/shims/python, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/gkapfham/.local/share/virtualenv)
    added seed packages: pip==20.1.1, setuptools==47.3.1, wheel==0.34.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment!
Virtualenv location: /home/gkapfham/.local/share/virtualenvs/gatorgrader-EhHiZ3CP-/home/gkapfham/.pyenv/shims/python
Installing dependencies from Pipfile…
An error occurred while installing bandit! Will try again.
Installing initially failed dependencies…
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
Python 3.8.3
============================= test session starts ==============================
platform linux -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /home/gkapfham/working/source/gatorgrader, inifile: pytest.ini
plugins: sugar-0.9.3, cov-2.10.0
collected 925 items

tests/test_arguments.py ..........
tests/test_checkers.py .........................
tests/test_comments.py ........................................................................................................................................................
tests/test_constants.py .....................................
tests/test_display.py ......
tests/test_files.py ....................
tests/test_fragments.py ..............................................................................................................................................................................
tests/test_invoke.py ....................................
tests/test_leave.py ..........
tests/test_markdown.py ...................
tests/test_orchestrate.py ........................
tests/test_report.py ......
tests/test_repository.py ...........
tests/test_run.py ......
tests/test_util.py .............................................
tests/checks/test_check_ConfirmFileExists.py ...........
tests/checks/test_check_CountCommandOutput.py .....................
tests/checks/test_check_CountCommits.py ...........
tests/checks/test_check_CountFileLines.py ....................
tests/checks/test_check_CountFileParagraphs.py ....................
tests/checks/test_check_CountFileWords.py ....................
tests/checks/test_check_CountMarkdownTags.py ..........................
tests/checks/test_check_CountMultipleLineComments.py .................................
tests/checks/test_check_CountParagraphWords.py ....................
tests/checks/test_check_CountSingleLineComments.py .................................
tests/checks/test_check_ExecuteCommand.py ..........
tests/checks/test_check_ListChecks.py ....................
tests/checks/test_check_MatchCommandFragment.py ......................
tests/checks/test_check_MatchCommandRegex.py ................................
tests/checks/test_check_MatchFileFragment.py ......................
tests/checks/test_check_MatchFileRegex.py .......................

============================= 925 passed in 5.62s ==============================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant