|
2 | 2 |
|
3 | 3 | import subprocess |
4 | 4 | import sys |
| 5 | +import textwrap |
5 | 6 |
|
6 | 7 | import pytest |
7 | 8 |
|
@@ -75,3 +76,64 @@ def test_cli_mypy_args(): |
75 | 76 | assert False, 'No valid API to test' |
76 | 77 |
|
77 | 78 | assert output.stdout.strip() == expected.strip() |
| 79 | + |
| 80 | +def test_cli_pyright_config(): |
| 81 | + output = subprocess.run( |
| 82 | + [sys.executable, '-m', 'qtpy', 'pyright-config'], |
| 83 | + capture_output=True, |
| 84 | + check=True, |
| 85 | + encoding='utf-8', |
| 86 | + ) |
| 87 | + |
| 88 | + if qtpy.PYQT5: |
| 89 | + expected = textwrap.dedent(""" |
| 90 | + pyrightconfig.json: |
| 91 | + {"defineConstant": {"PYQT5": true, "PYSIDE2": false, "PYQT6": false, "PYSIDE6": false}} |
| 92 | +
|
| 93 | + pyproject.toml: |
| 94 | + [tool.pyright.defineConstant] |
| 95 | + PYQT5 = true |
| 96 | + PYSIDE2 = false |
| 97 | + PYQT6 = false |
| 98 | + PYSIDE6 = false |
| 99 | + """) |
| 100 | + elif qtpy.PYSIDE2: |
| 101 | + expected = textwrap.dedent(""" |
| 102 | + pyrightconfig.json: |
| 103 | + {"defineConstant": {"PYQT5": false, "PYSIDE2": true, "PYQT6": false, "PYSIDE6": false}} |
| 104 | +
|
| 105 | + pyproject.toml: |
| 106 | + [tool.pyright.defineConstant] |
| 107 | + PYQT5 = false |
| 108 | + PYSIDE2 = true |
| 109 | + PYQT6 = false |
| 110 | + PYSIDE6 = false |
| 111 | + """) |
| 112 | + elif qtpy.PYQT6: |
| 113 | + expected = textwrap.dedent(""" |
| 114 | + pyrightconfig.json: |
| 115 | + {"defineConstant": {"PYQT5": false, "PYSIDE2": false, "PYQT6": true, "PYSIDE6": false}} |
| 116 | +
|
| 117 | + pyproject.toml: |
| 118 | + [tool.pyright.defineConstant] |
| 119 | + PYQT5 = false |
| 120 | + PYSIDE2 = false |
| 121 | + PYQT6 = true |
| 122 | + PYSIDE6 = false |
| 123 | + """) |
| 124 | + elif qtpy.PYSIDE6: |
| 125 | + expected = textwrap.dedent(""" |
| 126 | + pyrightconfig.json: |
| 127 | + {"defineConstant": {"PYQT5": false, "PYSIDE2": false, "PYQT6": false, "PYSIDE6": true}} |
| 128 | +
|
| 129 | + pyproject.toml: |
| 130 | + [tool.pyright.defineConstant] |
| 131 | + PYQT5 = false |
| 132 | + PYSIDE2 = false |
| 133 | + PYQT6 = false |
| 134 | + PYSIDE6 = true |
| 135 | + """) |
| 136 | + else: |
| 137 | + assert False, 'No valid API to test' |
| 138 | + |
| 139 | + assert output.stdout.strip() == expected.strip() |
0 commit comments