forked from scrapinghub/shub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
36 lines (27 loc) · 1.03 KB
/
Copy pathtest_utils.py
File metadata and controls
36 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# coding=utf-8
import unittest
from mock import patch
from shub import utils
from click.testing import CliRunner
class UtilsTest(unittest.TestCase):
def setUp(self):
self.runner = CliRunner()
def test_dependency_version_from_setup_is_parsed_properly(self):
def check(cmd):
if cmd == 'python setup.py --version':
return setup_version
setup_version = ('Building lxml version 3.4.4.'
'\nBuilding without Cython.'
'\nUsing build configuration of libxslt 1.1.28'
'\n3.4.4')
with self.runner.isolated_filesystem():
with patch('shub.utils.run', side_effect=check) as mocked_run:
# given
mocked_run.return_value = setup_version
# when
version = utils._get_dependency_version('lxml')
# then
self.assertEquals('lxml-3.4.4', version)
if __name__ == '__main__':
unittest.main()