File: test_imports.py

package info (click to toggle)
python-globus-sdk 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,172 kB
  • sloc: python: 35,227; sh: 44; makefile: 35
file content (37 lines) | stat: -rw-r--r-- 984 bytes parent folder | download | duplicates (2)
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
37
"""
Various tests for imports from the SDK to ensure that our `__all__`
declarations are correct and complete.

To ensure that we aren't contaminating these tests with the current
interpreter's state, invoke these via subprocess check_call() calls.
These should all be using `shell=True` (the subprocess invoked interpreter
doesn't behave correctly without it).
"""

import os
import subprocess
import sys

import pytest

PYTHON_BINARY = os.environ.get("GLOBUS_TEST_PY", sys.executable)


@pytest.mark.parametrize(
    "importstring",
    [
        "from globus_sdk import *",
        "from globus_sdk import TransferClient, AuthClient, SearchClient",
    ],
)
def test_import_str(importstring):
    proc = subprocess.Popen(
        f'{PYTHON_BINARY} -c "{importstring}"',
        shell=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
    )
    status = proc.wait()
    assert status == 0, str(proc.communicate())
    proc.stdout.close()
    proc.stderr.close()