-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set number of processes/threads through DRAMATIQ_NPROCS, DRAMATIQ_NTH…
…READS. (#186) * Add coverage report exclusions for __init__.py and setup.py. * Allow setting number of processes/threads through env.
- Loading branch information
Showing
6 changed files
with
104 additions
and
22 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
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 |
---|---|---|
|
@@ -24,5 +24,7 @@ order_by_type = true | |
|
||
[coverage:report] | ||
omit = | ||
__init__.py | ||
django_dramatiq/setup.py | ||
*/migrations/* | ||
*/tests/* |
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,29 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from django_dramatiq.utils import getenv_int | ||
|
||
|
||
@pytest.mark.parametrize("value, default, expected", ( | ||
("42", None, 42), | ||
("invalid", 69, 69), | ||
("invalid", None, ValueError), | ||
("invalid", lambda: 96, 96), | ||
(None, 19, 19), | ||
(None, lambda: 78, 78), | ||
(None, "hello", "hello"), # returned default is not checked to be an int | ||
(None, lambda: "world", "world") # idem | ||
)) | ||
def test_getenv_int(value, default, expected): | ||
varname = "TEST_ENV_20250204" | ||
if value is not None: | ||
os.environ[varname] = value | ||
else: | ||
os.environ.pop(varname, None) | ||
|
||
if isinstance(expected, type) and issubclass(expected, Exception): | ||
with pytest.raises(expected): | ||
getenv_int(varname, default) | ||
else: | ||
assert getenv_int(varname, default) == expected |