Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode
workspace.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
3 changes: 2 additions & 1 deletion didyoumean/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Empty file. Might grow in the future."""
import didyoumean_api
from didyoumean import didyoumean_api
from didyoumean.didyoumean_internal import add_suggestions_to_exception
2 changes: 1 addition & 1 deletion didyoumean/didyoumean_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8
"""APIs to add suggestions to exceptions."""
from didyoumean_internal import add_suggestions_to_exception
import functools
import sys
from .didyoumean_internal import add_suggestions_to_exception


def didyoumean_decorator(func):
Expand Down
17 changes: 13 additions & 4 deletions didyoumean/didyoumean_api_tests.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# -*- coding: utf-8
"""Unit tests for didyoumean APIs."""
from didyoumean_api import didyoumean_decorator, didyoumean_contextmanager,\
didyoumean_postmortem, didyoumean_enablehook, didyoumean_disablehook
from didyoumean_common_tests import TestWithStringFunction,\
get_exception, no_exception, NoFileIoError, unittest_module
import contextlib
import sys
import os

from .didyoumean_api import (
didyoumean_decorator,
didyoumean_contextmanager,
didyoumean_postmortem,
didyoumean_enablehook,
didyoumean_disablehook)
from .didyoumean_common_tests import (
TestWithStringFunction,
get_exception,
no_exception,
NoFileIoError,
unittest_module
)

class ApiTest(TestWithStringFunction):
"""Tests about the didyoumean APIs.
Expand Down
3 changes: 2 additions & 1 deletion didyoumean/didyoumean_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"""Logic to add suggestions to exceptions."""
import keyword
import difflib
import didyoumean_re as re
import itertools
import inspect
import errno
import os
import sys
from collections import namedtuple

from didyoumean import didyoumean_re as re


#: Standard modules we'll consider while searching for symbols, for instance:
# - NameError and the name is an attribute of a std (imported or not) module
Expand Down
27 changes: 17 additions & 10 deletions didyoumean/didyoumean_internal_tests.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# -*- coding: utf-8
"""Unit tests for code in didyoumean_internal.py."""
from didyoumean_internal import quote, get_suggestion_string,\
add_string_to_exception, get_func_by_name,\
get_objects_in_frame, get_subclasses, get_types_for_str,\
get_types_for_str_using_inheritance,\
get_types_for_str_using_names
import didyoumean_common_tests as common
from didyoumean_common_tests import unittest_module,\
CommonTestOldStyleClass2,\
CommonTestNewStyleClass2 # to have these 2 in defined names
import itertools
import sys

from .didyoumean_internal import (
quote,
get_suggestion_string,
add_string_to_exception,
get_func_by_name,
get_objects_in_frame,
get_subclasses,
get_types_for_str,
get_types_for_str_using_inheritance,
get_types_for_str_using_names
)
from didyoumean import didyoumean_common_tests as common
from .didyoumean_common_tests import (
unittest_module,
CommonTestOldStyleClass2,
CommonTestNewStyleClass2
)

OLD_CLASS_SUPPORT = sys.version_info >= (3, 0)
IS_PYPY = hasattr(sys, "pypy_translation_info")
Expand Down
6 changes: 3 additions & 3 deletions didyoumean/didyoumean_re_tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8
"""Unit tests for regexps from didyoumean_re.py."""
import didyoumean_re as re
import sys
from didyoumean_internal import get_subclasses
from didyoumean_common_tests import unittest_module
from .didyoumean_internal import get_subclasses
from .didyoumean_common_tests import unittest_module
from didyoumean import didyoumean_re as re

NO_GROUP = ((), dict())
# Various technical flags to check more that meet the eyes in tests
Expand Down
28 changes: 20 additions & 8 deletions didyoumean/didyoumean_sugg_tests.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
# -*- coding: utf-8
"""Unit tests for get_suggestions_for_exception."""
from didyoumean_internal import get_suggestions_for_exception, quote, \
STAND_MODULES, AVOID_REC_MSG, \
APPLY_REMOVED_MSG, BUFFER_REMOVED_MSG, CMP_REMOVED_MSG, \
CMP_ARG_REMOVED_MSG, EXC_ATTR_REMOVED_MSG, LONG_REMOVED_MSG, \
MEMVIEW_ADDED_MSG, RELOAD_REMOVED_MSG, STDERR_REMOVED_MSG, \
BREAKPOINT_ADDED_MSG, NO_KEYWORD_ARG_MSG, COMMA_INSTEAD_OF_PERIOD_MSG
import didyoumean_common_tests as common
import didyoumean_re as re
import warnings
import sys
import math
import os
import tempfile
from shutil import rmtree

from .didyoumean_internal import (
get_suggestions_for_exception,
quote,
STAND_MODULES,
AVOID_REC_MSG,
APPLY_REMOVED_MSG,
BUFFER_REMOVED_MSG,
CMP_REMOVED_MSG,
CMP_ARG_REMOVED_MSG,
EXC_ATTR_REMOVED_MSG,
LONG_REMOVED_MSG,
MEMVIEW_ADDED_MSG,
RELOAD_REMOVED_MSG,
STDERR_REMOVED_MSG,
BREAKPOINT_ADDED_MSG,
NO_KEYWORD_ARG_MSG,
COMMA_INSTEAD_OF_PERIOD_MSG
)
import .didyoumean_common_tests as common
import .didyoumean_re as re

unittest_module = common.unittest_module

Expand Down
4 changes: 2 additions & 2 deletions didyoumean/readme_examples.py → readme_examples.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8
"""Code to generate examples in README.md."""
from didyoumean_internal import add_suggestions_to_exception
import didyoumean_common_tests as common
from didyoumean import add_suggestions_to_exception
from didyoumean import didyoumean_common_tests as common
import os


Expand Down