forked from ftobia/pytest-ordering
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for sparse ordinal behavior
- tests taken from existing PR ftobia#29 - gaps in start and end lists are filled with unordered items
- Loading branch information
1 parent
d2703f0
commit f156094
Showing
4 changed files
with
146 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def item_names_for(testdir): | ||
|
||
def _item_names_for(tests_content): | ||
# some strange code to extract sorted items | ||
items = testdir.getitems(tests_content) | ||
hook = testdir.config.hook | ||
hook.pytest_collection_modifyitems(session=items[0].session, | ||
config=testdir.config, items=items) | ||
return [item.name for item in items] | ||
|
||
return _item_names_for | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
def test_first(item_names_for): | ||
tests_content = """ | ||
import pytest | ||
def test_1(): pass | ||
@pytest.mark.first | ||
def test_2(): pass | ||
""" | ||
assert item_names_for(tests_content) == ['test_2', 'test_1'] | ||
|
||
|
||
def test_second(item_names_for): | ||
tests_content = """ | ||
import pytest | ||
def test_1(): pass | ||
def test_2(): pass | ||
def test_3(): pass | ||
def test_4(): pass | ||
@pytest.mark.second | ||
def test_5(): pass | ||
""" | ||
assert item_names_for(tests_content) == ['test_1', 'test_5', 'test_2', 'test_3', 'test_4'] | ||
|
||
|
||
def test_third(item_names_for): | ||
tests_content = """ | ||
import pytest | ||
def test_1(): pass | ||
def test_2(): pass | ||
def test_3(): pass | ||
@pytest.mark.third | ||
def test_4(): pass | ||
def test_5(): pass | ||
""" | ||
assert item_names_for(tests_content) == ['test_1', 'test_2', 'test_4', 'test_3', 'test_5'] | ||
|
||
|
||
def test_second_to_last(item_names_for): | ||
tests_content = """ | ||
import pytest | ||
def test_1(): pass | ||
@pytest.mark.second_to_last | ||
def test_2(): pass | ||
def test_3(): pass | ||
def test_4(): pass | ||
def test_5(): pass | ||
""" | ||
assert item_names_for(tests_content) == ['test_1', 'test_3', 'test_4', 'test_2', 'test_5'] | ||
|
||
|
||
def test_last(item_names_for): | ||
tests_content = """ | ||
import pytest | ||
@pytest.mark.last | ||
def test_1(): pass | ||
def test_2(): pass | ||
""" | ||
assert item_names_for(tests_content) == ['test_2', 'test_1'] | ||
|
||
|
||
def test_first_last(item_names_for): | ||
tests_content = """ | ||
import pytest | ||
@pytest.mark.last | ||
def test_1(): pass | ||
@pytest.mark.first | ||
def test_2(): pass | ||
def test_3(): pass | ||
""" | ||
assert item_names_for(tests_content) == ['test_2', 'test_3', 'test_1'] |