Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stsewd committed Jun 18, 2018
1 parent 5fd8abc commit 92513d5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions readthedocs/rtd_tests/tests/test_doc_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,16 @@ def setUp(self):
mock.ANY, # cache path
]

def assertArgsStartsWith(self, args, function_mock):
"""
Assert that each element of args of the mock start
with each element of args.
"""
args_mock, _ = function_mock.call_args
for arg, arg_mock in zip(args, args_mock):
if arg is not mock.ANY:
self.assertTrue(arg_mock.startswith(arg))

def test_install_core_requirements_sphinx(self):
python_env = Virtualenv(
version=self.version_sphinx,
Expand All @@ -1158,9 +1168,8 @@ def test_install_core_requirements_sphinx(self):
]
requirements = self.base_requirements + requirements_sphinx
args = self.pip_install_args + requirements
self.build_env_mock.run.assert_called_once_with(
*args, bin_path=mock.ANY
)
self.build_env_mock.run.assert_called_once()
self.assertArgsStartsWith(args, self.build_env_mock.run)

def test_install_core_requirements_mkdocs(self):
python_env = Virtualenv(
Expand All @@ -1175,9 +1184,8 @@ def test_install_core_requirements_mkdocs(self):
]
requirements = self.base_requirements + requirements_mkdocs
args = self.pip_install_args + requirements
self.build_env_mock.run.assert_called_once_with(
*args, bin_path=mock.ANY
)
self.build_env_mock.run.assert_called_once()
self.assertArgsStartsWith(args, self.build_env_mock.run)

def test_install_user_requirements(self):
"""
Expand Down

0 comments on commit 92513d5

Please sign in to comment.