1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
# -*- coding: utf-8 -*-
import enum
import re
from pytray import obj_load
def test_load_class():
# Test with a class
name = obj_load.full_name(enum.Enum)
assert name == "enum.Enum"
obj_type = obj_load.load_obj(name)
assert obj_type is enum.Enum
# Now test loading something that we haven't imported the module for
obj_type = obj_load.load_obj("argparse.ArgumentParser")
import argparse # pylint: disable=import-outside-toplevel
assert obj_type is argparse.ArgumentParser
# Test with builtin
name = obj_load.full_name(dict)
obj_load.load_obj(name)
def test_load_function():
name = obj_load.full_name(re.match)
assert name == "re.match"
assert obj_load.load_obj(name) is re.match
|