|
34 | 34 | "pandas": "https://pandas.pydata.org/pandas-docs/stable/"
|
35 | 35 | },
|
36 | 36 | )
|
37 |
| -s.move(templated_files, excludes=["docs/multiprocessing.rst", "README.rst", ".github/workflows/unittest.yml"]) |
| 37 | +s.move(templated_files, excludes=["docs/multiprocessing.rst", "README.rst", ".github/workflows/unittest.yml", "noxfile.py"]) |
38 | 38 |
|
39 | 39 | # ----------------------------------------------------------------------------
|
40 | 40 | # Fixup files
|
|
44 | 44 | [".coveragerc"], "google/cloud/__init__.py", "db_dtypes/requirements.py",
|
45 | 45 | )
|
46 | 46 |
|
47 |
| -s.replace( |
48 |
| - ["noxfile.py"], r"[\"']google[\"']", '"db_dtypes"', |
49 |
| -) |
50 |
| - |
51 |
| -s.replace( |
52 |
| - ["noxfile.py"], r"import shutil", "import re\nimport shutil", |
53 |
| -) |
54 |
| - |
55 |
| -s.replace( |
56 |
| - ["noxfile.py"], "--cov=google", "--cov=db_dtypes", |
57 |
| -) |
58 |
| - |
59 |
| -# There are no system tests for this package. |
60 |
| -old_sessions = """ |
61 |
| - "unit", |
62 |
| - "system", |
63 |
| - "cover", |
64 |
| - "lint", |
65 |
| -""" |
66 |
| - |
67 |
| -new_sessions = """ |
68 |
| - "lint", |
69 |
| - "unit", |
70 |
| - "unit_prerelease", |
71 |
| - "compliance", |
72 |
| - "compliance_prerelease", |
73 |
| - "cover", |
74 |
| -""" |
75 |
| - |
76 |
| -s.replace(["noxfile.py"], old_sessions, new_sessions) |
77 |
| - |
78 |
| -# Add compliance tests. |
79 |
| -s.replace( |
80 |
| - ["noxfile.py"], r"def default\(session\):", "def default(session, tests_path):" |
81 |
| -) |
82 |
| -s.replace(["noxfile.py"], r'os.path.join\("tests", "unit"\),', "tests_path,") |
83 |
| -s.replace( |
84 |
| - ["noxfile.py"], |
85 |
| - r'f"--junitxml=unit_{session.python}_sponge_log.xml",', |
86 |
| - r'f"--junitxml={os.path.split(tests_path)[-1]}_{session.python}_sponge_log.xml",', |
87 |
| -) |
88 |
| -s.replace( |
89 |
| - ["noxfile.py"], |
90 |
| - r''' |
91 |
| -@nox.session\(python=UNIT_TEST_PYTHON_VERSIONS\) |
92 |
| -def unit\(session\): |
93 |
| - """Run the unit test suite.""" |
94 |
| - default\(session\) |
95 |
| -''', |
96 |
| - r''' |
97 |
| -def prerelease(session, tests_path): |
98 |
| - constraints_path = str( |
99 |
| - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" |
100 |
| - ) |
101 |
| -
|
102 |
| - # PyArrow prerelease packages are published to an alternative PyPI host. |
103 |
| - # https://arrow.apache.org/docs/python/install.html#installing-nightly-packages |
104 |
| - session.install( |
105 |
| - "--extra-index-url", |
106 |
| - "https://pypi.fury.io/arrow-nightlies/", |
107 |
| - "--prefer-binary", |
108 |
| - "--pre", |
109 |
| - "--upgrade", |
110 |
| - "pyarrow", |
111 |
| - ) |
112 |
| - # Avoid pandas==2.2.0rc0 as this version causes PyArrow to fail. Once newer |
113 |
| - # prerelease comes out, this constraint can be removed. See |
114 |
| - # https://github.com/googleapis/python-db-dtypes-pandas/issues/234 |
115 |
| - session.install( |
116 |
| - "--extra-index-url", |
117 |
| - "https://pypi.anaconda.org/scipy-wheels-nightly/simple", |
118 |
| - "--prefer-binary", |
119 |
| - "--pre", |
120 |
| - "--upgrade", |
121 |
| - "pandas!=2.2.0rc0", |
122 |
| - ) |
123 |
| - session.install( |
124 |
| - "mock", |
125 |
| - "asyncmock", |
126 |
| - "pytest", |
127 |
| - "pytest-cov", |
128 |
| - "pytest-asyncio", |
129 |
| - "-c", |
130 |
| - constraints_path, |
131 |
| - ) |
132 |
| -
|
133 |
| - # Because we test minimum dependency versions on the minimum Python |
134 |
| - # version, the first version we test with in the unit tests sessions has a |
135 |
| - # constraints file containing all dependencies and extras. |
136 |
| - with open( |
137 |
| - CURRENT_DIRECTORY |
138 |
| - / "testing" |
139 |
| - / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", |
140 |
| - encoding="utf-8", |
141 |
| - ) as constraints_file: |
142 |
| - constraints_text = constraints_file.read() |
143 |
| -
|
144 |
| - # Ignore leading whitespace and comment lines. |
145 |
| - deps = [ |
146 |
| - match.group(1) |
147 |
| - for match in re.finditer( |
148 |
| - r"^\\s*(\\S+)(?===\\S+)", constraints_text, flags=re.MULTILINE |
149 |
| - ) |
150 |
| - ] |
151 |
| -
|
152 |
| - # We use --no-deps to ensure that pre-release versions aren't overwritten |
153 |
| - # by the version ranges in setup.py. |
154 |
| - session.install(*deps) |
155 |
| - session.install("--no-deps", "-e", ".") |
156 |
| -
|
157 |
| - # Print out prerelease package versions. |
158 |
| - session.run("python", "-m", "pip", "freeze") |
159 |
| -
|
160 |
| - # Run py.test against the unit tests. |
161 |
| - session.run( |
162 |
| - "py.test", |
163 |
| - "--quiet", |
164 |
| - f"--junitxml={os.path.split(tests_path)[-1]}_prerelease_{session.python}_sponge_log.xml", |
165 |
| - "--cov=db_dtypes", |
166 |
| - "--cov=tests/unit", |
167 |
| - "--cov-append", |
168 |
| - "--cov-config=.coveragerc", |
169 |
| - "--cov-report=", |
170 |
| - "--cov-fail-under=0", |
171 |
| - tests_path, |
172 |
| - *session.posargs, |
173 |
| - ) |
174 |
| -
|
175 |
| -
|
176 |
| -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1]) |
177 |
| -def compliance(session): |
178 |
| - """Run the compliance test suite.""" |
179 |
| - default(session, os.path.join("tests", "compliance")) |
180 |
| -
|
181 |
| -
|
182 |
| -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1]) |
183 |
| -def compliance_prerelease(session): |
184 |
| - """Run the compliance test suite with prerelease dependencies.""" |
185 |
| - prerelease(session, os.path.join("tests", "compliance")) |
186 |
| -
|
187 |
| -
|
188 |
| -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) |
189 |
| -def unit(session): |
190 |
| - """Run the unit test suite.""" |
191 |
| - default(session, os.path.join("tests", "unit")) |
192 |
| -
|
193 |
| -
|
194 |
| -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1]) |
195 |
| -def unit_prerelease(session): |
196 |
| - """Run the unit test suite with prerelease dependencies.""" |
197 |
| - prerelease(session, os.path.join("tests", "unit")) |
198 |
| -''', |
199 |
| -) |
200 |
| - |
201 | 47 | # ----------------------------------------------------------------------------
|
202 | 48 | # Samples templates
|
203 | 49 | # ----------------------------------------------------------------------------
|
|
0 commit comments