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_csh fails on Solaris due to unexpected prompt in the output #2409

Closed
kulikjak opened this issue Sep 1, 2022 · 5 comments · Fixed by #2418
Closed

test_csh fails on Solaris due to unexpected prompt in the output #2409

kulikjak opened this issue Sep 1, 2022 · 5 comments · Fixed by #2418
Labels

Comments

@kulikjak
Copy link
Contributor

kulikjak commented Sep 1, 2022

Issue

When running the virtualenv test suite on Solaris, I can see both tests in tests/unit/activation/test_csh.py fail.

    def test_csh(activation_tester_class, activation_tester):
        class Csh(activation_tester_class):
            def __init__(self, session):
                super().__init__(CShellActivator, session, "csh", "activate.csh", "csh")

            def print_prompt(self):
                return "echo 'source \"$VIRTUAL_ENV/bin/activate.csh\"; echo $prompt' | csh -i"

>       activation_tester(Csh)

.....

    def assert_output(self, out, raw, tmp_path):
        # pre-activation
        assert out[0], raw
        assert out[1] == "None", raw
        # post-activation
        expected = self._creator.exe.parent / os.path.basename(sys.executable)
        assert self.norm_path(out[2]) == self.norm_path(expected), raw
        assert self.norm_path(out[3]) == self.norm_path(self._creator.dest).replace("\\\\", "\\"), raw
        # Some attempts to test the prompt output print more than 1 line.
        # So we need to check if the prompt exists on any of them.
        prompt_text = f"({self._creator.env_name}) "
        assert any(prompt_text in line for line in out[4:-3]), raw

>       assert out[-3] == "wrote pydoc_test.html", raw
E       AssertionError: /..../virtualenv/virtualenv-20.16.3/.tox/py39/bin/python
E         None
E         /tmp/pytest-of-jkulik/pytest-39/activation-tester-env9/e-$ __________-j/bin/python
E         /tmp/pytest-of-jkulik/pytest-39/activation-tester-env9/e-$ __________-j
E         Warning: no access to tty; thus no job control in this shell...
E         myvm-i386-25280% (e-$ __________-j) myvm-i386-25280%
E         (e-$ __________-j) myvm-i386-25280% wrote pydoc_test.html
E         /..../virtualenv/virtualenv-20.16.3/.tox/py39/bin/python
E         None
E
E       assert '(e-$ __________...doc_test.html' == 'wrote pydoc_test.html'
E         - wrote pydoc_test.html
E         + (e-$ __________-j) myvm-i386-25280% wrote pydoc_test.html

I executed the test suite simply by downloading the sources (from PyPI) and running tox in that directory. I can see the same thing when running pytest directly.

It seems that the test suite doesn't expect the prompt to be there and I can easily fix that when I replace assert out[-3] == "wrote pydoc_test.html", raw with assert "wrote pydoc_test.html" in out[-3], raw though I am not sure whether I can do that.

Environment

  • OS: Oracle Solaris 11.4
  • virtualenv 20.16.3
@kulikjak kulikjak added the bug label Sep 1, 2022
@gaborbernat
Copy link
Contributor

The prompt is supposed to be on its own, see https://github.com/pypa/virtualenv/blob/main/tests/unit/activation/conftest.py#L117, so I'm not sure here.

@kulikjak
Copy link
Contributor Author

Thanks for the pointer, I think I found the issue. Testing this on Linux I noticed that it uses tcsh and on Solaris we have the original csh, and there is a slight difference in how those work in this case - tcsh ends with a new line and our csh does not (which is why the wrote pydoc_test.html line is prefixed in our case).

When I modify test_csh.py to run tcsh -i instead, the test passes. It also work if I append additional ; echo there.

So I presume that virtualenv expects tcsh to be the Cshell available on the machine?

@gaborbernat
Copy link
Contributor

We expect it to work with csh, but wasn't aware of the differences of tcsh. So you can say this behaviour is a bug.

@kulikjak
Copy link
Contributor Author

Good to know. Well, adding that ; echo into the print_prompt function seems to work no matter whether csh or tcsh is used (there is just an additional newline in the tcsh case). Should I open PR with that? Or do you prefer to fix this some other way?

@gaborbernat
Copy link
Contributor

. Should I open PR with that?

Go ahead, thanks!

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

Successfully merging a pull request may close this issue.

2 participants