Last active
July 2, 2024 05:10
-
-
Save joshprice/864ca419c6e8f47000757977f3ff6db2 to your computer and use it in GitHub Desktop.
Buildkite Python Test Collector with xdist
This file contains hidden or 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
def add(a, b): | |
return a + b | |
def subtract(a, b): | |
return a - b |
This file contains hidden or 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
[pytest] | |
log_cli = True | |
log_cli_level = DEBUG |
This file contains hidden or 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
pytest | |
pytest-xdist | |
buildkite-test-collector |
This file contains hidden or 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
import pytest | |
import time | |
class TestClassOne: | |
def test_one(self): | |
time.sleep(0.5) # Simulate some work | |
assert True | |
def test_two(self): | |
time.sleep(0.4) # Simulate more work | |
assert 1 == 1 | |
def test_two_again(self): | |
time.sleep(0.3) # Simulate some work | |
assert "a" in "abc" | |
def test_one_again(self): | |
time.sleep(0.6) # Simulate very quick work | |
assert isinstance([], list) |
This file contains hidden or 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
from main import add, subtract | |
def test_add(): | |
assert add(2, 3) == 5 | |
def test_subtract(): | |
assert subtract(5, 3) == 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test run with
-n 2
and 6 tests, 2 in functional style, 4 in class style. No duplicates are seen, API payload is only sent once.