Skip to content

Commit

Permalink
refactor: run bad args for callable test for python3.8/3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Apr 11, 2024
1 parent 87e5c23 commit a3ed3e1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion openedx_events/event_bus/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""

import copy
import sys
import pytest
import warnings
from contextlib import contextmanager
from unittest import TestCase
Expand Down Expand Up @@ -83,8 +85,9 @@ def test_missing_attribute(self):
)
assert loaded == {'def': 'ault'}

@pytest.mark.skipif(sys.version_info < (3, 8), reason="requires Python 3.8+")
@override_settings(EB_LOAD_PATH='builtins.dict')
def test_bad_args_for_callable(self):
def test_bad_args_for_callable_python38(self):
with assert_warnings([
"Failed to load <class 'dict'> from setting EB_LOAD_PATH: "
"TypeError('type object argument after * must be an iterable, not int'); "
Expand All @@ -96,6 +99,20 @@ def test_bad_args_for_callable(self):
)
assert loaded == {'def': 'ault'}

@pytest.mark.skipif(sys.version_info < (3, 11), reason="requires Python 3.11+")
@override_settings(EB_LOAD_PATH='builtins.dict')
def test_bad_args_for_callable_python311(self):
with assert_warnings([
"Failed to load <class 'dict'> from setting EB_LOAD_PATH: "
"TypeError('dict() argument after * must be an iterable, not int'); "
"component will be inactive"
]):
loaded = _try_load(
setting_name="EB_LOAD_PATH", args=(1), kwargs={'2': 3},
expected_class=dict, default={'def': 'ault'},
)
assert loaded == {'def': 'ault'}


class TestProducer(TestCase):

Expand Down

0 comments on commit a3ed3e1

Please sign in to comment.