File: test_obj_load.py

package info (click to toggle)
python-pytray 0.3.5-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 192 kB
  • sloc: python: 510; sh: 30; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 746 bytes parent folder | download | duplicates (2)
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