PY-20071 Fixed: Nonexistent logger methods should be mark as unresolved

PY-19716 Fixed: logger.exception() without arguments doesn't show a warning

Skeleton for logging.getLogger was accidentally pushed to primary python-skeletons repo and then was synced with current repo.
So there is no skeleton in affected files but tests are based on it.

At first logger.getLogger returned union of Logger and RootLogger.
RootLogger just inherits Logger and doesn't introduce any additional functionality.
But there was a problem with PyArgumentListInspection which doesn't work in case of many callees (e.g. logger.exception).
So skeleton was updated to return only logger from logging.getLogger.
This commit is contained in:
Semyon Proshev
2016-10-13 21:08:52 +03:00
parent c9590508a0
commit 565e1307e7
7 changed files with 42 additions and 0 deletions
@@ -1,5 +1,8 @@
"""Skeleton for 'logging' stdlib module."""
import logging
def getLogger(name=None):
"""
:type name: string
@@ -0,0 +1,9 @@
def getLogger():
pass
def exception(msg):
pass
class Logger(object):
def exception(self, msg):
pass
@@ -0,0 +1,5 @@
import logging
logger = logging.getLogger()
logger.exception(<warning descr="Parameter 'msg' unfilled">)</warning>
logging.exception(<warning descr="Parameter 'msg' unfilled">)</warning>
@@ -0,0 +1,4 @@
import logging
logger = logging.getLogger()
logger.<warning descr="Unresolved attribute reference 'foobar' for class 'Logger'">foobar</warning>()
@@ -0,0 +1,6 @@
def getLogger():
pass
class Logger(object):
def exception(self, msg):
pass
@@ -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) + "/";
@@ -729,6 +729,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
doTest();
}
// PY-20071
public void testNonexistentLoggerMethod() {
doMultiFileTest();
}
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {