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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
|
--- a/tests/core/test_utilities.py
+++ b/tests/core/test_utilities.py
@@ -24,8 +24,6 @@
from hypothesis import strategies as st
import numpy as np
import pytest
-from pytest_cases import parametrize
-from pytest_cases import parametrize_with_cases
from scipy.spatial.transform import Rotation
import vtk
@@ -1674,40 +1672,6 @@
)
-@parametrize(copy=[True, False])
-@parametrize_with_cases(
- ('obj', 'return_self', 'return_type', 'return_dtype'), cases=CasesTransformApply
-)
-def test_transform_apply(transform, obj, return_self, return_type, return_dtype, copy):
- def _get_points_from_object(obj_):
- return (
- obj_.points
- if isinstance(obj_, pv.DataSet)
- else obj_[0].points
- if isinstance(obj_, pv.MultiBlock)
- else obj_
- )
-
- points_in_array = np.array(_get_points_from_object(obj))
- out = transform.scale(SCALE).apply(obj, copy=copy)
-
- if not copy and return_self:
- assert out is obj
- else:
- assert out is not obj
- assert isinstance(out, return_type)
-
- points_out = _get_points_from_object(out)
- assert isinstance(points_out, np.ndarray)
- assert points_out.dtype == return_dtype
- assert np.array_equal(points_in_array * SCALE, points_out)
-
- inverted = transform.apply(out, inverse=True)
- inverted_points = _get_points_from_object(inverted)
- assert np.array_equal(inverted_points, points_in_array)
- assert not transform.is_inverted
-
-
@pytest.fixture
def scale_transform():
return Transform() * SCALE
@@ -2445,18 +2409,6 @@
return qual.active_scalars[0]
-@parametrize('info', _CELL_QUALITY_INFO, ids=CELL_QUALITY_IDS)
-@pytest.mark.needs_vtk_version(9, 2)
-def test_cell_quality_info_valid_measures(info):
- # Ensure the computed measure is not null
- null_value = -1
- qual_value = _compute_unit_cell_quality(info, null_value)
- if np.isclose(qual_value, null_value):
- pytest.fail(
- f'Measure {info.quality_measure!r} is not valid for cell type {info.cell_type.name!r}'
- )
-
-
def xfail_wedge_negative_volume(info):
if info.cell_type == pv.CellType.WEDGE and info.quality_measure == 'volume':
pytest.xfail(
@@ -2474,31 +2426,6 @@
)
-@parametrize('info', _CELL_QUALITY_INFO, ids=CELL_QUALITY_IDS)
-@pytest.mark.needs_vtk_version(9, 2)
-def test_cell_quality_info_unit_cell_value(info):
- """Test that the actual computed measure for a unit cell matches the reported value."""
- xfail_wedge_negative_volume(info)
-
- unit_cell_value = info.unit_cell_value
- qual_value = _compute_unit_cell_quality(info)
- assert np.isclose(qual_value, unit_cell_value)
-
-
-@parametrize('info', _CELL_QUALITY_INFO, ids=CELL_QUALITY_IDS)
-@pytest.mark.needs_vtk_version(9, 2)
-def test_cell_quality_info_acceptable_range(info):
- """Test that the unit cell value is within the acceptable range."""
- # Some cells / measures have bugs and return invalid values and are expected to fail
- xfail_wedge_negative_volume(info)
-
- acceptable_range = info.acceptable_range
- unit_cell_value = info.unit_cell_value
-
- assert unit_cell_value >= acceptable_range[0]
- assert unit_cell_value <= acceptable_range[1]
-
-
def _replace_range_infinity(rng):
rng = list(rng)
lower, upper = rng
@@ -2509,45 +2436,6 @@
return rng
-@parametrize('info', _CELL_QUALITY_INFO, ids=CELL_QUALITY_IDS)
-@pytest.mark.needs_vtk_version(9, 2)
-def test_cell_quality_info_normal_range(info):
- """Test that the normal range is broader than the acceptable range."""
- acceptable_range = _replace_range_infinity(info.acceptable_range)
- normal_range = _replace_range_infinity(info.normal_range)
-
- assert normal_range[0] <= acceptable_range[0]
- assert normal_range[1] >= acceptable_range[1]
-
-
-@parametrize('info', _CELL_QUALITY_INFO, ids=CELL_QUALITY_IDS)
-@pytest.mark.needs_vtk_version(9, 2)
-def test_cell_quality_info_full_range(info):
- """Test that the full range is broader than the normal range."""
- normal_range = _replace_range_infinity(info.normal_range)
- full_range = _replace_range_infinity(info.full_range)
-
- assert full_range[0] <= normal_range[0]
- assert full_range[1] >= normal_range[1]
-
-
-@parametrize('info', _CELL_QUALITY_INFO, ids=CELL_QUALITY_IDS)
-@pytest.mark.needs_vtk_version(9, 2)
-def test_cell_quality_info_degenerate_cell(info):
- # Some cells / measures have bugs and return invalid values and are expected to fail
- xfail_distortion_returns_one(info)
-
- # Compare non-generate cell with degenerate cell with coincident point(s)
- unit_cell_quality = _compute_unit_cell_quality(info, coincident=False)
- all_coincident_quality = _compute_unit_cell_quality(info, coincident='all')
- single_coincident_quality = _compute_unit_cell_quality(info, coincident='single')
-
- # Quality must differ in at least one of the degeneracy cases
- assert (not np.isclose(unit_cell_quality, all_coincident_quality)) or (
- not np.isclose(unit_cell_quality, single_coincident_quality)
- )
-
-
@pytest.mark.needs_vtk_version(9, 2)
def test_cell_quality_info_raises():
match = re.escape(
--- a/tests/examples/test_cell_examples.py
+++ b/tests/examples/test_cell_examples.py
@@ -4,7 +4,6 @@
import numpy as np
import pytest
-from pytest_cases import parametrize
import pyvista
from pyvista import CellType
@@ -16,36 +15,6 @@
]
-@pytest.mark.needs_vtk_version(9, 1, 0)
-@parametrize('cell_example', cell_example_functions)
-def test_area_and_volume(cell_example):
- mesh = cell_example()
- assert isinstance(mesh, pyvista.UnstructuredGrid)
- assert mesh.n_cells == 1
-
- if mesh.celltypes[0] in [
- pyvista.CellType.BIQUADRATIC_QUADRATIC_HEXAHEDRON,
- pyvista.CellType.TRIQUADRATIC_HEXAHEDRON,
- ]:
- pytest.xfail(
- 'Volume should be positive but returns zero, see https://gitlab.kitware.com/vtk/vtk/-/issues/19639'
- )
-
- # Test area and volume
- dim = mesh.GetCell(0).GetCellDimension()
- area = mesh.area
- volume = mesh.volume
- if dim == 2:
- assert area > 0
- assert np.isclose(volume, 0.0)
- elif dim == 3:
- assert np.isclose(area, 0.0)
- assert volume > 0
- else:
- assert np.isclose(area, 0.0)
- assert np.isclose(volume, 0.0)
-
-
def test_empty():
grid = cells.Empty()
assert grid.celltypes[0] == CellType.EMPTY_CELL
--- a/tests/examples/test_download_files.py
+++ b/tests/examples/test_download_files.py
@@ -14,7 +14,6 @@
import numpy as np
import pytest
-from pytest_cases import parametrize
import pyvista as pv
from pyvista import examples
@@ -596,72 +595,6 @@
assert 'frame0' in dataset.point_data
-@parametrize(high_resolution=[True, False])
-def test_download_black_vase(high_resolution: bool):
- filename = examples.download_black_vase(load=False, high_resolution=high_resolution)
- assert Path(filename).is_file()
- assert filename.endswith('vtp')
-
- dataset = examples.download_black_vase(load=True, high_resolution=high_resolution)
- assert isinstance(dataset, pv.PolyData)
- assert dataset.n_points == 17_337 if not high_resolution else 1_611_789
-
-
-@parametrize(high_resolution=[True, False])
-def test_download_ivan_angel(high_resolution: bool):
- filename = examples.download_ivan_angel(load=False, high_resolution=high_resolution)
- assert Path(filename).is_file()
- assert filename.endswith('vtp')
-
- dataset = examples.download_ivan_angel(load=True, high_resolution=high_resolution)
- assert isinstance(dataset, pv.PolyData)
- assert dataset.n_points == 18_412 if not high_resolution else 1_811_531
-
-
-@parametrize(high_resolution=[True, False])
-def test_download_bird_bath(high_resolution: bool):
- filename = examples.download_bird_bath(load=False, high_resolution=high_resolution)
- assert Path(filename).is_file()
- assert filename.endswith('vtp')
-
- dataset = examples.download_bird_bath(load=True, high_resolution=high_resolution)
- assert isinstance(dataset, pv.PolyData)
- assert dataset.n_points == 18_796 if not high_resolution else 1_831_383
-
-
-@parametrize(high_resolution=[True, False])
-def test_download_owl(high_resolution: bool):
- filename = examples.download_owl(load=False, high_resolution=high_resolution)
- assert Path(filename).is_file()
- assert filename.endswith('vtp')
-
- dataset = examples.download_owl(load=True, high_resolution=high_resolution)
- assert isinstance(dataset, pv.PolyData)
- assert dataset.n_points == 12442 if not high_resolution else 1_221_756
-
-
-@parametrize(high_resolution=[True, False])
-def test_download_plastic_vase(high_resolution: bool):
- filename = examples.download_plastic_vase(load=False, high_resolution=high_resolution)
- assert Path(filename).is_file()
- assert filename.endswith('vtp')
-
- dataset = examples.download_plastic_vase(load=True, high_resolution=high_resolution)
- assert isinstance(dataset, pv.PolyData)
- assert dataset.n_points == 18238 if not high_resolution else 1_796_805
-
-
-@parametrize(high_resolution=[True, False])
-def test_download_sea_vase(high_resolution: bool):
- filename = examples.download_sea_vase(load=False, high_resolution=high_resolution)
- assert Path(filename).is_file()
- assert filename.endswith('vtp')
-
- dataset = examples.download_sea_vase(load=True, high_resolution=high_resolution)
- assert isinstance(dataset, pv.PolyData)
- assert dataset.n_points == 18_063 if not high_resolution else 1_810_012
-
-
def test_download_sparse_points():
filename = examples.download_sparse_points(load=False)
assert Path(filename).is_file()
@@ -816,12 +749,6 @@
assert isinstance(dataset, pv.PolyData)
-@parametrize(high_resolution=[True, False])
-def test_download_action_figure(high_resolution: bool):
- dataset = examples.download_action_figure(high_resolution=high_resolution)
- assert isinstance(dataset, pv.PolyData)
-
-
def test_download_notch_stress():
dataset = examples.download_notch_stress()
assert isinstance(dataset, pv.UnstructuredGrid)
@@ -1161,36 +1088,6 @@
assert isinstance(mesh, pv.ExplicitStructuredGrid)
-@parametrize(high_resolution=[True, False])
-def test_download_whole_body_ct_male(high_resolution: bool):
- filename = examples.download_whole_body_ct_male(load=False, high_resolution=high_resolution)
-
- if not high_resolution:
- assert (p := (Path(filename))).is_file()
- assert p.suffix == '.vtm'
-
- dataset: pv.MultiBlock = examples.download_whole_body_ct_male(
- load=True, high_resolution=high_resolution
- )
- assert isinstance(dataset, pv.MultiBlock)
- npoints = max(b.n_points for b in dataset.recursive_iterator())
- assert npoints == 6_988_800 if not high_resolution else 56_012_800
-
-
-@parametrize(high_resolution=[True, False])
-def test_download_whole_body_ct_female(high_resolution: bool):
- filename = examples.download_whole_body_ct_female(load=False, high_resolution=high_resolution)
-
- if not high_resolution:
- assert (p := (Path(filename))).is_file()
- assert p.suffix == '.vtm'
-
- dataset = examples.download_whole_body_ct_female(load=True, high_resolution=high_resolution)
- assert isinstance(dataset, pv.MultiBlock)
- npoints = max(b.n_points for b in dataset.recursive_iterator())
- assert npoints == 6_937_600 if not high_resolution else 55_603_200
-
-
def test_download_headsq():
filename = examples.download_headsq(load=False)
assert (p := Path(filename)).is_file()
@@ -1218,30 +1115,6 @@
assert isinstance(mesh, pv.ImageData)
-@parametrize(partial=[True, False])
-@pytest.mark.needs_vtk_version(9, 1, less_than=(9, 2)) # 9.1 for HDFReader, 9.2 for example
-def test_download_can(partial: bool):
- filename = examples.download_can(load=False, partial=partial)
-
- if partial:
- assert (p := (Path(filename))).is_file()
- assert p.suffix == '.hdf'
- else:
- assert all(Path(f).is_file() for f in filename)
- assert all(Path(f).suffix == '.hdf' for f in filename)
-
- dataset: pv.UnstructuredGrid = examples.download_can(load=True, partial=partial)
- assert isinstance(dataset, pv.UnstructuredGrid)
- assert dataset.n_points == 6724 if partial else 20_172
-
-
-@parametrize(partial=[True, False])
-@pytest.mark.needs_vtk_version(9, 2)
-def test_download_can_raises(partial: bool):
- with pytest.raises(pv.VTKVersionError):
- examples.download_can(partial=partial)
-
-
def test_download_fea_bracket():
filename = examples.download_fea_bracket(load=False)
assert (p := Path(filename)).is_file()
--- a/tests/test_conftest.py
+++ b/tests/test_conftest.py
@@ -5,10 +5,6 @@
from typing import TYPE_CHECKING
import pytest
-from pytest_cases import case
-from pytest_cases import filters as ft
-from pytest_cases import parametrize
-from pytest_cases import parametrize_with_cases
import pyvista
@@ -175,279 +171,6 @@
assert 'test_downloads' in (report.passed if cml else report.skipped)
-class CasesNeedsVtk:
- @case
- @parametrize(greater=[True, False])
- def case_min_only(self, greater: bool, monkeypatch: pytest.MonkeyPatch):
- """Test when using the args, with both tuple and variadic *args and the kwargs"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(9, 1)
- def test_greater_9_1(): ...
-
- @pytest.mark.needs_vtk_version((9, 1))
- def test_greater_9_1_tuple(): ...
-
- @pytest.mark.needs_vtk_version((9, 1, 0))
- def test_greater_9_1_tuple_2(): ...
-
- @pytest.mark.needs_vtk_version(at_least=(9, 1))
- def test_greater_9_1_kwargs(): ...
-
- @pytest.mark.needs_vtk_version(at_least=(9, 2))
- def test_greater_9_2(): ...
- """
-
- value = (8, 2, 0) if greater else (9, 2, 0)
- monkeypatch.setattr(pyvista, 'vtk_version_info', value)
-
- return tests, dict(passed=0 if greater else 5, skipped=5 if greater else 0)
-
- @case
- @parametrize(lower=[True, False])
- def case_max_only(self, lower: bool, monkeypatch: pytest.MonkeyPatch):
- """Test when using the max kwargs"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(less_than=(9, 1))
- def test_smaller_9_1(): ...
-
- @pytest.mark.needs_vtk_version(less_than=(9,))
- def test_smaller_9(): ...
-
- @pytest.mark.needs_vtk_version(less_than=(9, 1, 2))
- def test_smaller_9_1_2(): ...
-
- """
-
- value = (8, 2, 0) if lower else (9, 2, 0)
- monkeypatch.setattr(pyvista, 'vtk_version_info', value)
-
- return tests, dict(passed=3 if lower else 0, skipped=0 if lower else 3)
-
- @case
- def case_max_equal(self, monkeypatch: pytest.MonkeyPatch):
- """Test when the max version equals the current"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(less_than=(9, 1))
- def test_smaller_9_1_tuple1(): ...
-
- @pytest.mark.needs_vtk_version(less_than=(9, 1, 0))
- def test_smaller_9_1_tuple2(): ...
-
- """
-
- monkeypatch.setattr(pyvista, 'vtk_version_info', (9, 1, 0))
-
- return tests, dict(skipped=2)
-
- @case
- def case_min_equal(self, monkeypatch: pytest.MonkeyPatch):
- """Test when the min version equals the current"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(at_least=(9, 1))
- def test_smaller_9_1_tuple1(): ...
-
- """
-
- monkeypatch.setattr(pyvista, 'vtk_version_info', (9, 1, 0))
-
- return tests, dict(passed=1)
-
- def case_multiple_decorating(self, monkeypatch: pytest.MonkeyPatch):
- """Test when decorating multiple times"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(9, 1)
- @pytest.mark.needs_vtk_version(less_than=(9, 3))
- def test_1(): ...
-
- @pytest.mark.needs_vtk_version(less_than=(9, 3))
- @pytest.mark.needs_vtk_version(9, 1)
- def test_2(): ...
-
- """
-
- monkeypatch.setattr(pyvista, 'vtk_version_info', (8, 2, 0))
-
- return tests, dict(skipped=2)
-
- @case
- @parametrize(between=[True, False])
- def case_min_max(self, between: bool, monkeypatch: pytest.MonkeyPatch):
- """Test when using both min and max kwargs"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(at_least=(8, 2), less_than=(9, 1))
- def test_between(): ...
-
- @pytest.mark.needs_vtk_version((8, 2), less_than=(9, 1))
- def test_between_tuple(): ...
-
- @pytest.mark.needs_vtk_version(8, 2, less_than=(9, 1))
- def test_between_variadic(): ...
-
- @pytest.mark.needs_vtk_version(8, 2, less_than=(9, 2))
- def test_between_variadic_max_equals(): ...
-
- @pytest.mark.needs_vtk_version(9, less_than=(9, 2))
- def test_between_variadic_min_equals(): ...
-
- """
-
- value = (9, 0, 0) if between else (9, 2, 0)
- monkeypatch.setattr(pyvista, 'vtk_version_info', value)
-
- return tests, dict(passed=5 if between else 0, skipped=0 if between else 5)
-
- @case(tags='raises')
- def case_raises_signature(self):
- """Test when not specifying any version, or using bad signature"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version
- def test_1(): ...
-
- @pytest.mark.needs_vtk_version(foo=1)
- def test_2(): ...
-
- """
-
- return tests, dict(errors=2)
-
- @case(tags='raises')
- def case_raises_both_args_min_kwargs(self):
- """Test when specifying both args and min kwargs"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(9, 2, 1, at_least=(8, 1))
- def test_1(): ...
-
- @pytest.mark.needs_vtk_version((9, 2), at_least=(9, 1))
- def test_2(): ...
- """
-
- return tests, dict(errors=2)
-
- @case(tags='raises')
- def case_min_greater_max(self):
- """Test when specifying min > max"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(9, 2, 1, less_than=(8, 1))
- def test_1(): ...
-
- @pytest.mark.needs_vtk_version((9, 2, 1), less_than=(8, 1))
- def test_2(): ...
- """
-
- return tests, dict(errors=2)
-
- @case(tags='raises')
- def case_version_tuple_wrong(self):
- """Test when specifying a tuple of len > 3"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(9, 2, 1, 2)
- def test_1(): ...
-
- @pytest.mark.needs_vtk_version(less_than=(8, 1, 0, 1))
- def test_2(): ...
- """
-
- return tests, dict(errors=2)
-
- @case(tags='reason')
- def case_reason_default(self, monkeypatch: pytest.MonkeyPatch):
- """Test the reason kwargs"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(9, 1)
- def test_1(): ...
-
- @pytest.mark.needs_vtk_version(9, 1, less_than=(9, 2))
- def test_2(): ...
-
- @pytest.mark.needs_vtk_version(less_than=(8, 1))
- def test_3(): ...
-
- """
-
- monkeypatch.setattr(pyvista, 'vtk_version_info', (8, 2))
-
- return tests, [
- r'SKIPPED.*Test needs VTK version >= \(9, 1, 0\), current is \(8, 2\)',
- r'SKIPPED.*Test needs \(9, 1, 0\) <= VTK version < \(9, 2, 0\), current is \(8, 2\).',
- r'SKIPPED.*Test needs VTK version < \(8, 1, 0\), current is \(8, 2\).',
- ]
-
- @case(tags='reason')
- def case_reason_custom(self, monkeypatch: pytest.MonkeyPatch):
- """Test the custom reason kwargs"""
-
- tests = """
- import pytest
-
- @pytest.mark.needs_vtk_version(9, 1, reason="foo")
- def test(): ...
-
- """
-
- monkeypatch.setattr(pyvista, 'vtk_version_info', (8, 2))
-
- return tests, ['SKIPPED.*foo']
-
-
-@parametrize_with_cases(
- 'tests, outcome', cases=CasesNeedsVtk, filter=~ft.has_tag('raises') & ~ft.has_tag('reason')
-)
-def test_needs_vtk_version(tests: str, outcome: dict, pytester: pytest.Pytester):
- p = pytester.makepyfile(tests)
- results = pytester.runpytest(p)
-
- results.assert_outcomes(**outcome)
-
-
-@parametrize_with_cases('tests, outcome', cases=CasesNeedsVtk, has_tag='raises')
-def test_needs_vtk_version_raises(tests: str, outcome: dict, pytester: pytest.Pytester):
- p = pytester.makepyfile(tests)
- results = pytester.runpytest(p)
-
- results.assert_outcomes(**outcome)
-
-
-@parametrize_with_cases('tests, match', cases=CasesNeedsVtk, has_tag='reason')
-def test_needs_vtk_version_reason(tests: str, match: list[str], pytester: pytest.Pytester):
- p = pytester.makepyfile(tests)
- results = pytester.runpytest(p)
-
- results.stdout.re_match_lines(match)
-
-
@pytest.mark.skipif(os.name != 'nt', reason='Needs Windows platform to run')
def test_skip_windows(
pytester: pytest.Pytester,
@@ -556,74 +279,3 @@
m = mocker.patch.object(platform, 'system')
m.return_value = 'Darwin'
-
-
-@pytest.mark.usefixtures('_patch_mac_system')
-@parametrize(processor=['foo', None], machine=['bar', None])
-def test_skip_mac(
- pytester: pytest.Pytester,
- results_parser: PytesterStdoutParser,
- mocker: MockerFixture,
- processor: str | None,
- machine: str | None,
-):
- tests = """
- import pytest
-
- @pytest.mark.skip_mac
- def test_skipped():
- ...
-
- def test_not_skipped():
- ...
-
- @pytest.mark.skip_mac(foo=1)
- def test_skipped_wrong():
- ...
-
- @pytest.mark.skip_mac(processor="foo", machine="bar")
- def test_skipped_platform_machine():
- ...
-
- """
-
- import platform
-
- m = mocker.patch.object(platform, 'processor')
- m.return_value = processor
-
- m = mocker.patch.object(platform, 'machine')
- m.return_value = machine
-
- p = pytester.makepyfile(tests)
- results = pytester.runpytest(p)
-
- results.stdout.re_match_lines(
- [
- r'.*Marker `skip_mac` called with incorrect arguments\.',
- r'.*Signature should be: @pytest\.mark\.skip_mac\(reason.*processor.*machine.*\)',
- ]
- )
-
- skipped = 1
- skipped += 1 if (processor is not None and machine is not None) else 0
-
- passed = 2
- passed -= 1 if (processor is not None and machine is not None) else 0
-
- results.assert_outcomes(
- skipped=skipped,
- passed=passed,
- errors=1,
- )
-
- results = results_parser.parse(results=results)
- report = RunResultsReport(results)
-
- assert 'test_not_skipped' in report.passed
- assert 'test_skipped' in report.skipped
- assert 'test_skipped_wrong' in report.error
- if processor is not None and machine is not None:
- assert 'test_skipped_platform_machine' in report.skipped
- else:
- assert 'test_skipped_platform_machine' in report.passed
|