Commit e18fade
authored
tests: migrate from nosetests to pytest (#1134)
* Dockerfile: replace pipenv with python3-pytest; quote pyroute2 version
- drop pipenv (unused)
- add python3-pytest from apt (available in bullseye at 6.0.2)
- quote 'pyroute2>=0.5.17' so the shell does not strip the >= operator
* tests: switch test runner from nosetests to pytest
python3-nose crashes on Python 3.11+ (collections.Callable removed in
3.10; nose/suite.py still uses it). pytest is the modern replacement
and is now installed via apt alongside python3-nose (kept for the
nose.tools helpers that a few tests still use).
Makefile changes:
- NOSETESTS → PYTEST variable using `which pytest`
- TEST_ARGUMENT format: nose --where/--tests style → pytest path style
(tests/*.py for all, tests/foo.py for a named test)
- Use tests/*.py glob (not tests/) to avoid descending into
tests/tablespaces/ which has its own import layout and make target
Makefile.citus: apply the same TEST_ARGUMENT pattern update that the
main Makefile received.
* tests: fix pytest compatibility — binary path, CI gating, network locale, conftest, autocommit
1. Makefile: use 'python3 -m pytest' instead of 'which pytest'
Debian's python3-pytest package does not install a 'pytest' binary in
PATH (only 'py.test-3' and 'pytest-3'); 'python3 -m pytest' is the
reliable invocation regardless of binary name.
2. .github/workflows/run-tests.yml: gate build_images on style_checker
so a style failure stops CI before any image builds start.
3. tests/network.py: two fixes for pyroute2 >= 0.5.17 strict UTF-8:
- replace universal_newlines=True with encoding='utf-8',
errors='replace' in both NSPopen calls so non-ASCII bytes from
pg_autoctl are replaced rather than raising UnicodeDecodeError.
- add LC_ALL=C LANG=C to subprocess env so PostgreSQL produces
ASCII-only error messages inside network namespaces.
4. tests/tablespaces/conftest.py: add project root to sys.path so
the tablespace tests can import as 'from tests.tablespaces.xxx'.
nosetests did this implicitly; pytest does not.
5. tests/pgautofailover_utils.py: fix run_sql_query when autocommit=True.
psycopg2's 'with conn:' context manager wraps an implicit BEGIN even
when autocommit is on (behaviour varies by psycopg2 version), blocking
DDL like CREATE TABLESPACE. Use explicit commit/rollback/finally.1 parent 5e91db1 commit e18fade
7 files changed
Lines changed: 36 additions & 19 deletions
File tree
- .github/workflows
- tests
- tablespaces
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | 47 | | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
175 | 174 | | |
176 | 175 | | |
177 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| |||
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
| 184 | + | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
282 | | - | |
283 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
284 | 289 | | |
285 | 290 | | |
286 | 291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments