-
Notifications
You must be signed in to change notification settings - Fork 20
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
Break the unit test suite's reliance on os.environ #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def docker_env_vars(monkeypatch): | ||
"""Monkeypatch environment variables that we'd get running under docker.""" | ||
monkeypatch.setenv('PHABRICATOR_URL', 'http://phabricator.test') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're going to change the phab url, can you also go through and update all the canned responses to use this URL? Right now they use the default mozphab.aws URL which came from the original docker-compose.yml. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
monkeypatch.setenv('TRANSPLANT_URL', 'http://autoland.test') |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
from tests.canned_responses.phabricator.repos import * | ||
from tests.canned_responses.phabricator.errors import * | ||
|
||
pytestmark = pytest.mark.usefixtures('docker_env_vars') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that if you also move this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore the specifics above, but, otherwise is there a better way to have this be done automatically for every test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Importing the fixture won't apply it - you need to include a fixture in the module's |
||
|
||
|
||
def test_get_revision_with_200_response(): | ||
phab = PhabricatorClient(api_key='api-key') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a file
tests/utils.py
which contains utility and setup functions that every test uses. Can you move this function to that file? Unless there is a purpose for this file in the near future. I just want to avoid having a bunch of test setup across different files.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind! I see that conftest.py is a common pattern with pytest.