Skip to content

Conversation

@jiasli
Copy link
Member

@jiasli jiasli commented Mar 26, 2021

Description

src/azure-cli-core/azure/cli/core/tests/test_util.py::TestUtils::test_open_page_in_browser fails on WSL:

_mock_self = <MagicMock name='open' spec='function' id='139689703216128'>, args = ('http://foo', 2), kwargs = {}
self = <MagicMock name='open' spec='function' id='139689703216128'>
msg = "Expected 'open' to be called once. Called 0 times."

    def assert_called_once_with(_mock_self, *args, **kwargs):
        """assert that the mock was called exactly once and that that call was
        with the specified arguments."""
        self = _mock_self
        if not self.call_count == 1:
            msg = ("Expected '%s' to be called once. Called %s times.%s"
                   % (self._mock_name or 'mock',
                      self.call_count,
                      self._calls_repr()))
>           raise AssertionError(msg)
E           AssertionError: Expected 'open' to be called once. Called 0 times.

env38/lib/python3.8/site-packages/mock/mock.py:925: AssertionError

Now fix it!

@jiasli jiasli changed the title {Core} Fix test_open_page_in_browser on WSL {Core} Fix test_open_page_in_browser on WSL Mar 26, 2021
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe
# Ampersand (&) should be quoted
return subprocess.call(['powershell.exe', '-Command', 'Start-Process "{}"'.format(url)])
return subprocess.Popen(['powershell.exe', '-Command', 'Start-Process "{}"'.format(url)])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start-Process is async, so no need to use call to wait for the result.

@yonzhan yonzhan added this to the S185 milestone Mar 26, 2021
@yonzhan
Copy link
Collaborator

yonzhan commented Mar 26, 2021

Core

@jiasli jiasli merged commit cbd54d5 into Azure:dev Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants