Skip to content

Commit 2254c78

Browse files
committed
GH-5: Create a fixture for getting the list of available backends
1 parent 72ddf3c commit 2254c78

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/conftest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import importlib
2+
import os
3+
4+
import pytest
5+
import social_core.backends as backends
6+
from social_core.backends.oauth import BaseOAuth2
7+
8+
package_path = backends.__path__[0]
9+
10+
11+
@pytest.fixture
12+
def backends():
13+
backend_instances = []
14+
for module in os.listdir(package_path):
15+
try:
16+
module_instance = importlib.import_module("social_core.backends.%s" % module[:-3])
17+
backend_instances.extend([
18+
attr for attr in module_instance.__dict__.values()
19+
if type(attr) is type and all([
20+
issubclass(attr, BaseOAuth2),
21+
attr is not BaseOAuth2,
22+
])
23+
])
24+
except ImportError:
25+
continue
26+
return backend_instances

0 commit comments

Comments
 (0)