Files
zulip/tools/tests/test_hash_reqs.py
Aman Agrawal 685ec2a098 hash_reqs: Include python version when generating hash.
Fixes #12868.
We now also include python version in the format
'major.minor.patchlevel', when generating hash for a
requirement file. This was necessary since packages tend to
break on different versions of python, so it is important to
track the version on which the venv was setup.

WARN: This commit will force all zulip venvs to be recreated.
2020-07-13 13:06:15 -07:00

26 lines
836 B
Python

import unittest
import mock
from scripts.lib.hash_reqs import expand_reqs, hash_deps
from tools.setup.setup_venvs import DEV_REQS_FILE
class TestHashCreation(unittest.TestCase):
def test_diff_hash_for_diff_python_version(self) -> None:
with mock.patch('scripts.lib.hash_reqs.python_version', return_value='Python 3.6.9'):
deps = expand_reqs(DEV_REQS_FILE)
hash1 = hash_deps(deps)
with mock.patch('scripts.lib.hash_reqs.python_version', return_value='Python 3.6.9'):
deps = expand_reqs(DEV_REQS_FILE)
hash2 = hash_deps(deps)
with mock.patch('scripts.lib.hash_reqs.python_version', return_value='Python 3.8.2'):
deps = expand_reqs(DEV_REQS_FILE)
hash3 = hash_deps(deps)
assert hash1 == hash2
assert hash1 != hash3