diff --git a/python/helpers/python-skeletons/logging.py b/python/helpers/python-skeletons/logging.py index cb25d7aa43b5..f121dbe263c4 100644 --- a/python/helpers/python-skeletons/logging.py +++ b/python/helpers/python-skeletons/logging.py @@ -1,5 +1,8 @@ """Skeleton for 'logging' stdlib module.""" +import logging + + def getLogger(name=None): """ :type name: string diff --git a/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/logging.py b/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/logging.py new file mode 100644 index 000000000000..205bc4ce65fc --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/logging.py @@ -0,0 +1,9 @@ +def getLogger(): + pass + +def exception(msg): + pass + +class Logger(object): + def exception(self, msg): + pass \ No newline at end of file diff --git a/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/methodsForLoggingExceptions.py b/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/methodsForLoggingExceptions.py new file mode 100644 index 000000000000..80adb1ad2032 --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/methodsForLoggingExceptions.py @@ -0,0 +1,5 @@ +import logging + +logger = logging.getLogger() +logger.exception() +logging.exception() \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/a.py b/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/a.py new file mode 100644 index 000000000000..b4f337fe5995 --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/a.py @@ -0,0 +1,4 @@ +import logging + +logger = logging.getLogger() +logger.foobar() \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/logging.py b/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/logging.py new file mode 100644 index 000000000000..9e6ae8ae6d2d --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/logging.py @@ -0,0 +1,6 @@ +def getLogger(): + pass + +class Logger(object): + def exception(self, msg): + pass \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java index a0800d50c069..225f3b193ce5 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java @@ -212,6 +212,16 @@ public class PyArgumentListInspectionTest extends PyTestCase { doTest(); } + // PY-19716 + public void testMethodsForLoggingExceptions() { + final String folderPath = "inspections/PyArgumentListInspection/" + getTestName(false) + "/"; + + myFixture.copyDirectoryToProject(folderPath, ""); + myFixture.configureFromTempProjectFile("methodsForLoggingExceptions.py"); + myFixture.enableInspections(PyArgumentListInspection.class); + myFixture.checkHighlighting(true, false, false); + } + // PY-19522 public void testCsvRegisterDialect() { final String folderPath = "inspections/PyArgumentListInspection/" + getTestName(false) + "/"; diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java index 3b2548bddaeb..197301c6811f 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java @@ -729,6 +729,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase { doTest(); } + // PY-20071 + public void testNonexistentLoggerMethod() { + doMultiFileTest(); + } + @NotNull @Override protected Class getInspectionClass() {