forked from quantumlib/Cirq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion_test.py
31 lines (26 loc) · 1.19 KB
/
version_test.py
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
# Copyright 2021 The Cirq Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Dict, Any
from dev_tools import modules
def test_versions_are_the_same():
mods = modules.list_modules(include_parent=True)
versions = {m.name: m.version for m in mods}
assert len(set(versions.values())) == 1, f"Versions should be the same, instead: \n{versions}"
def _get_version(package: str):
version_file = f'{package}/_version.py'
resulting_locals: Dict[str, Any] = {}
exec(open(version_file).read(), globals(), resulting_locals)
__version__ = resulting_locals['__version__']
assert __version__, f"__version__ should be defined in {version_file}"
return __version__