googleapis / python-storage

Apache License 2.0
440 stars 151 forks source link

Add a system test to ensure the "google" namespace isn't clobbered #1179

Open andrewsg opened 11 months ago

andrewsg commented 11 months ago

Once google-api-core and googleapis-common-protos have adopted native namespace packaging and removed their __init__.py files in the google namespace, then we should add a test that validates that this package and all dependencies do not interfere with further use of the google namespace.

Test follows:

import os
import subprocess
import sys
import tempfile

def test_namespace_package_compat():
    """
    The ``google`` namespace package should not be masked
    by the presence of this package.
    """
    with tempfile.TemporaryDirectory() as tmp_path:
        google = tmp_path + "/google"
        os.mkdir(google)
        path = os.path.join(google, "othermod.py")
        with open(path, "w") as f:
            f.write("pass")
        env = dict(os.environ, PYTHONPATH=tmp_path)
        cmd = [sys.executable, "-m", "google.othermod"]
        subprocess.check_call(cmd, env=env)
frankyn commented 7 months ago

Hi @andrewsg Is this issue unblocked now?