-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
More robusts tests for requirements_file and conda_file #4394
More robusts tests for requirements_file and conda_file #4394
Conversation
}) | ||
@mock.patch('readthedocs.projects.models.Project.checkout_path') | ||
def test_conda_with_cofig(self, checkout_path): | ||
base_path = tempfile.mkdtemp() |
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.
I wasn't able to reuse the apply_fs
function (only works with pytest) or fake_paths
as the check is very strict.
@@ -40,14 +44,30 @@ def inner(path=None, env_config=None): | |||
return inner | |||
|
|||
|
|||
@mock.patch('readthedocs.doc_builder.config.load_config') |
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.
I have to remove the class level mock and only used it in some methods
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.
Looks good!
""" | ||
Creates a readthedocs configuration file with name | ||
``file_name`` in ``base_path``. If ``base_path`` is not given | ||
a temporal directory is created. |
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.
nit: not to change now, but just to consider that PEP257 (https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings) says that we need one summary line, a blank line, and a more elaborate description.
I know that you love following PEPs ;)
NOTE: this is checked automatically by one of our linters and it will fail in that case.
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.
haha, yeah
|
||
full_requirements_file = path.join(base_path, requirements_file) | ||
with open(full_requirements_file, 'w') as f: | ||
f.write('pip') |
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.
Do we need to create this file at all for the test?
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.
Yeah, the validation is very strict, and it checks that the file exists, I wasn't able to mock this one. But I'm using pytest for our new tests, and we don't need to use this hacks anymore
2703a5b
to
773cbff
Compare
Rebased and updated |
773cbff
to
d8c173c
Compare
d8c173c
to
0774e23
Compare
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.
LGTM!
Previous tests were mocking the
load_config
function, now we are testing it for realRelated to #4379