Debian Codegraph @

tests/unit/test_packaging.py

raw
1 # Copyright 2023 Google LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import os
16 import subprocess
17 import sys
18
19
20 def test_namespace_package_compat(tmp_path):
21 """
22 The ``google`` namespace package should not be masked
23 by the presence of ``googleapis-common-protos``.
24 """
25 google = tmp_path / "google"
26 google.mkdir()
27 google.joinpath("othermod.py").write_text("")
28 env = dict(os.environ, PYTHONPATH=str(tmp_path))
29 cmd = [sys.executable, "-m", "google.othermod"]
30 subprocess.check_call(cmd, env=env)
31
32 """
33 The ``google.cloud`` namespace package should not be masked
34 by the presence of ``googleapis-common-protos``.
35 """
36 google_cloud = tmp_path / "google/cloud"
37 google_cloud.mkdir()
38 google_cloud.joinpath("othermod.py").write_text("")
39 env = dict(os.environ, PYTHONPATH=str(tmp_path))
40 cmd = [sys.executable, "-m", "google.cloud.othermod"]
41 subprocess.check_call(cmd, env=env)
42
43 """
44 The ``google.logging`` namespace package should not be masked
45 by the presence of ``googleapis-common-protos``.
46 """
47 google_logging = tmp_path / "google/logging"
48 google_logging.mkdir()
49 google_logging.joinpath("othermod.py").write_text("")
50 env = dict(os.environ, PYTHONPATH=str(tmp_path))
51 cmd = [sys.executable, "-m", "google.logging.othermod"]
52 subprocess.check_call(cmd, env=env)