@@ -419,10 +419,6 @@ separate test functions, these test functions are handled separately from the
419
419
test classes. If a module has no test classes, the effect is the same as
420
420
if using ``--order-scope=module ``.
421
421
422
- .. note ::
423
- This option only affects ordinal ordering. Ordering relative to other tests
424
- is always global, as the related tests are referenced by name.
425
-
426
422
For example consider two test modules:
427
423
428
424
**tests/test_module1.py **:
@@ -568,17 +564,74 @@ only if the scope is less than the order scope, e.g. there are three
568
564
possibilities:
569
565
570
566
- order scope "session", order group scope "module" - this is shown in the
571
- example above: first tests in eac module are ordered, afterwards the modules
567
+ example above: first tests in each module are ordered, afterwards the modules
572
568
- order scope "module", order group scope "class" - first orders tests inside
573
569
each class, then the classes inside each module
574
570
- order scope "session", order group scope "class" - first orders tests inside
575
571
each class, then the classes inside each module, and finally the modules
576
572
relatively to each other
577
573
574
+ This option will also work with relative markers.
575
+
576
+ Here is a similar example using relative markers:
577
+
578
+ **tests/test_module1.py **:
579
+
580
+ .. code ::
581
+
582
+ import pytest
583
+
584
+ @pytest.mark.order(after="test_module2.test1")
585
+ def test1():
586
+ pass
587
+
588
+ def test2():
589
+ pass
590
+
591
+ **tests/test_module2.py **:
592
+
593
+ .. code ::
594
+
595
+ import pytest
596
+
597
+ def test1():
598
+ pass
599
+
600
+ @pytest.mark.order(before="test1")
601
+ def test2():
602
+ pass
603
+
604
+ Here is what you get using different scopes:
605
+
606
+ ::
607
+
608
+ $ pytest tests -vv
609
+ ============================= test session starts ==============================
610
+ ...
611
+
612
+ tests/test_module1.py:5: test2 PASSED
613
+ tests/test_module2.py:9: test1 PASSED
614
+ tests/test_module2.py:5: test2 PASSED
615
+ tests/test_module1.py:9: test1 PASSED
616
+
617
+ ::
618
+
619
+ $ pytest tests -vv --order-group-scope=module
620
+ ============================= test session starts ==============================
621
+ ...
622
+
623
+ tests/test_module2.py:9: test1 PASSED
624
+ tests/test_module2.py:5: test2 PASSED
625
+ tests/test_module1.py:9: test1 PASSED
626
+ tests/test_module1.py:5: test2 PASSED
627
+
628
+ You can see that in the second run the second test module is run before the
629
+ first because of the dependency, but the tests inside each module remain in
630
+ the same order as before. Note that using module scope as in the example
631
+ above doesn't make sense here due to the dependencies between modules.
632
+
578
633
.. note ::
579
- This option currently does not work with relative markers - respective
580
- support may be added later. It will also not work together with the sparse
581
- ordering option.
634
+ This option will not work together well with the sparse ordering option.
582
635
583
636
``--indulgent-ordering ``
584
637
------------------------
0 commit comments