Add test for fixup_module_metadata
This commit is contained in:
@@ -13,6 +13,12 @@ import os
|
||||
|
||||
def fixup_module_metadata(namespace):
|
||||
def fix_one(qualname, name, obj):
|
||||
# Custom extension, to handle classmethods, staticmethods and properties
|
||||
if isinstance(obj, (classmethod, staticmethod)):
|
||||
obj = obj.__func__
|
||||
if isinstance(obj, property):
|
||||
obj = obj.fget
|
||||
|
||||
mod = getattr(obj, "__module__", None)
|
||||
if mod is not None and mod.startswith("fbchat."):
|
||||
obj.__module__ = "fbchat"
|
||||
|
16
tests/test_module_renaming.py
Normal file
16
tests/test_module_renaming.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import fbchat
|
||||
|
||||
|
||||
def test_module_renaming():
|
||||
assert fbchat.Message.__module__ == "fbchat"
|
||||
assert fbchat.Group.__module__ == "fbchat"
|
||||
assert fbchat.Event.__module__ == "fbchat"
|
||||
assert fbchat.User.block.__module__ == "fbchat"
|
||||
assert fbchat.Session.login.__func__.__module__ == "fbchat"
|
||||
assert fbchat.Session._from_session.__func__.__module__ == "fbchat"
|
||||
assert fbchat.Message.session.fget.__module__ == "fbchat"
|
||||
assert fbchat.Session.__repr__.__module__ == "fbchat"
|
||||
|
||||
|
||||
def test_did_not_rename():
|
||||
assert fbchat._graphql.queries_to_json.__module__ != "fbchat"
|
Reference in New Issue
Block a user