The following issues were found
Lib/tty.py
223 issues
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Line: 5
Column: 1
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
Reported by Pylint.
Lib/multiprocessing/managers.py
223 issues
Line: 27
Column: 1
import os
from os import getpid
from traceback import format_exc
from . import connection
from .context import reduction, get_spawning_popen, ProcessError
from . import pool
from . import process
Reported by Pylint.
Line: 29
Column: 1
from traceback import format_exc
from . import connection
from .context import reduction, get_spawning_popen, ProcessError
from . import pool
from . import process
from . import util
from . import get_context
Reported by Pylint.
Line: 30
Column: 1
from traceback import format_exc
from . import connection
from .context import reduction, get_spawning_popen, ProcessError
from . import pool
from . import process
from . import util
from . import get_context
try:
Reported by Pylint.
Line: 31
Column: 1
from . import connection
from .context import reduction, get_spawning_popen, ProcessError
from . import pool
from . import process
from . import util
from . import get_context
try:
from . import shared_memory
Reported by Pylint.
Line: 32
Column: 1
from . import connection
from .context import reduction, get_spawning_popen, ProcessError
from . import pool
from . import process
from . import util
from . import get_context
try:
from . import shared_memory
except ImportError:
Reported by Pylint.
Line: 33
Column: 1
from .context import reduction, get_spawning_popen, ProcessError
from . import pool
from . import process
from . import util
from . import get_context
try:
from . import shared_memory
except ImportError:
HAS_SHMEM = False
Reported by Pylint.
Line: 34
Column: 1
from . import pool
from . import process
from . import util
from . import get_context
try:
from . import shared_memory
except ImportError:
HAS_SHMEM = False
else:
Reported by Pylint.
Line: 368
Column: 1
util.debug('manager received shutdown message')
c.send(('#RETURN', None))
except:
import traceback
traceback.print_exc()
finally:
self.stop_event.set()
def create(self, c, typeid, /, *args, **kwds):
Reported by Pylint.
Line: 900
Column: 31
kwds['authkey'] = self._authkey
if getattr(self, '_isauto', False):
kwds['exposed'] = self._exposed_
return (RebuildProxy,
(AutoProxy, self._token, self._serializer, kwds))
else:
return (RebuildProxy,
(type(self), self._token, self._serializer, kwds))
Reported by Pylint.
Line: 1334
Column: 17
# shared_memory manipulation both in the manager and in the
# current process does not create two resource_tracker
# processes.
from . import resource_tracker
resource_tracker.ensure_running()
BaseManager.__init__(self, *args, **kwargs)
util.debug(f"{self.__class__.__name__} created by pid {getpid()}")
def __del__(self):
Reported by Pylint.
Lib/tarfile.py
222 issues
Line: 316
Column: 21
"w": os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
}[mode]
if hasattr(os, "O_BINARY"):
mode |= os.O_BINARY
self.fd = os.open(name, mode, 0o666)
def close(self):
os.close(self.fd)
Reported by Pylint.
Line: 579
Column: 5
self.fileobj = fileobj
self.buf = self.fileobj.read(BLOCKSIZE)
def read(self, size):
self.read = self.fileobj.read
return self.buf
def getcomptype(self):
if self.buf.startswith(b"\x1f\x8b\x08"):
Reported by Pylint.
Line: 1523
Column: 36
try:
if self.mode == "r":
self.firstmember = None
self.firstmember = self.next()
if self.mode == "a":
# Move to the end of the archive,
# before the first empty block.
while True:
Reported by Pylint.
Line: 2392
Column: 23
members.
"""
while True:
tarinfo = self.next()
if tarinfo is None:
break
self._loaded = True
def _check(self, mode=None):
Reported by Pylint.
Line: 2439
Column: 23
# happen that getmembers() is called during iteration,
# which will have already exhausted the next() method.
if self.firstmember is not None:
tarinfo = self.next()
index += 1
yield tarinfo
while True:
if index < len(self.members):
Reported by Pylint.
Line: 2447
Column: 27
if index < len(self.members):
tarinfo = self.members[index]
elif not self._loaded:
tarinfo = self.next()
if not tarinfo:
self._loaded = True
return
else:
return
Reported by Pylint.
Line: 189
Column: 13
s = nts(s, "ascii", "strict")
n = int(s.strip() or "0", 8)
except ValueError:
raise InvalidHeaderError("invalid header")
return n
def itn(n, digits=8, format=DEFAULT_FORMAT):
"""Convert a python number to a number field.
"""
Reported by Pylint.
Line: 192
Column: 22
raise InvalidHeaderError("invalid header")
return n
def itn(n, digits=8, format=DEFAULT_FORMAT):
"""Convert a python number to a number field.
"""
# POSIX 1003.1-1988 requires numbers to be encoded as a string of
# octal digits followed by a null-byte, this allows values up to
# (8**(digits-1))-1. GNU tar allows storing numbers greater than
Reported by Pylint.
Line: 203
Column: 5
# base-256 representation. This allows values up to (256**(digits-1))-1.
# A 0o200 byte indicates a positive number, a 0o377 byte a negative
# number.
original_n = n
n = int(n)
if 0 <= n < 8 ** (digits - 1):
s = bytes("%0*o" % (digits - 1, n), "ascii") + NUL
elif format == GNU_FORMAT and -256 ** (digits - 1) <= n < 256 ** (digits - 1):
if n >= 0:
Reported by Pylint.
Line: 214
Column: 13
s = bytearray([0o377])
n = 256 ** digits + n
for i in range(digits - 1):
s.insert(1, n & 0o377)
n >>= 8
else:
raise ValueError("overflow in number field")
Reported by Pylint.
Lib/test/test_email/test_headerregistry.py
221 issues
Line: 118
Column: 3
self.assertEqual(len(h.defects), 1)
self.assertIsInstance(h.defects, tuple)
# XXX: FIXME
#def test_CR_in_value(self):
# # XXX: this also re-raises the issue of embedded headers,
# # need test and solution for that.
# value = '\r'.join(['this is', ' a test'])
# h = self.make_header('subject', value)
Reported by Pylint.
Line: 120
Column: 8
# XXX: FIXME
#def test_CR_in_value(self):
# # XXX: this also re-raises the issue of embedded headers,
# # need test and solution for that.
# value = '\r'.join(['this is', ' a test'])
# h = self.make_header('subject', value)
# self.assertEqual(h, value)
# self.assertDefectsEqual(h.defects, [errors.ObsoleteHeaderDefect])
Reported by Pylint.
Line: 510
Column: 3
{'b\uFFFDr': 'two', 'baz': 'thr\uFFFDe'},
[errors.UndecodableBytesDefect]*3,
'foo�/bar; b�r="two"; baz="thr�e"',
# XXX Two bugs here: the mime type is not allowed to be an encoded
# word, and we shouldn't be emitting surrogates in the parameter
# names. But I don't know what the behavior should be here, so I'm
# punting for now. In practice this is unlikely to be encountered
# since headers with binary in them only come from a binary source
# and are almost certain to be re-emitted without refolding.
Reported by Pylint.
Line: 711
Column: 3
{'charset': 'utf-8”'},
[errors.UndecodableBytesDefect],
'text/plain; charset="utf-8”"',
# XXX Should folding change the charset to utf8? Currently it just
# reproduces the original, which is arguably fine.
"Content-Type: text/plain;"
" charset*=unknown-8bit''utf-8%E2%80%9D\n",
),
Reported by Pylint.
Line: 746
Column: 3
'application/x-foo; name="My Document For You"',
),
# XXX: I would say this one should default to ascii/en for the
# "encoded" segment, since the first segment is not encoded and is
# in double quotes, making the value a valid non-encoded string. The
# old parser decodes this just like the previous case, which may be the
# better Postel rule, but could equally result in borking headers that
# intentionally have quoted quotes in them. We could get this 98%
Reported by Pylint.
Line: 1230
Column: 3
}
# XXX: Need many more examples, and in particular some with names in
# trailing comments, which aren't currently handled. comments in
# general are not handled yet.
def example_as_address(self, source, defects, decoded, display_name,
addr_spec, username, domain, comment):
Reported by Pylint.
Line: 1235
Column: 57
# general are not handled yet.
def example_as_address(self, source, defects, decoded, display_name,
addr_spec, username, domain, comment):
h = self.make_header('sender', source)
self.assertEqual(h, decoded)
self.assertDefectsEqual(h.defects, defects)
a = h.address
self.assertEqual(str(a), decoded)
Reported by Pylint.
Line: 1248
Column: 3
self.assertEqual(a.addr_spec, addr_spec)
self.assertEqual(a.username, username)
self.assertEqual(a.domain, domain)
# XXX: we have no comment support yet.
#self.assertEqual(a.comment, comment)
def example_as_group(self, source, defects, decoded, display_name,
addr_spec, username, domain, comment):
source = 'foo: {};'.format(source)
Reported by Pylint.
Line: 1252
Column: 55
#self.assertEqual(a.comment, comment)
def example_as_group(self, source, defects, decoded, display_name,
addr_spec, username, domain, comment):
source = 'foo: {};'.format(source)
gdecoded = 'foo: {};'.format(decoded) if decoded else 'foo:;'
h = self.make_header('to', source)
self.assertEqual(h, gdecoded)
self.assertDefectsEqual(h.defects, defects)
Reported by Pylint.
Line: 1292
Column: 3
', '.join([x[0] for x in examples[4:6]]) + ';,' +
', '.join([x[0] for x in examples[6:]])
)
# XXX: the fact that (empty) disappears here is a potential API design
# bug. We don't currently have a way to preserve comments.
expected = ('dummy list:;, another:;, ' +
', '.join([x[2] for x in examples[:4]]) + ', ' +
r'"A \"list\"": ' +
', '.join([x[2] for x in examples[4:6]]) + ';, ' +
Reported by Pylint.
Lib/test/seq_tests.py
220 issues
Line: 63
Column: 5
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
def __iter__(self):
return self
class IterGenExc:
'Test propagation of exceptions'
def __init__(self, seqn):
Reported by Pylint.
Line: 107
Column: 13
l1 = [0]
l2 = [0, 1]
u = self.type2test()
u0 = self.type2test(l0)
u1 = self.type2test(l1)
u2 = self.type2test(l2)
uu = self.type2test(u)
Reported by Pylint.
Line: 108
Column: 14
l2 = [0, 1]
u = self.type2test()
u0 = self.type2test(l0)
u1 = self.type2test(l1)
u2 = self.type2test(l2)
uu = self.type2test(u)
uu0 = self.type2test(u0)
Reported by Pylint.
Line: 109
Column: 14
u = self.type2test()
u0 = self.type2test(l0)
u1 = self.type2test(l1)
u2 = self.type2test(l2)
uu = self.type2test(u)
uu0 = self.type2test(u0)
uu1 = self.type2test(u1)
Reported by Pylint.
Line: 110
Column: 14
u = self.type2test()
u0 = self.type2test(l0)
u1 = self.type2test(l1)
u2 = self.type2test(l2)
uu = self.type2test(u)
uu0 = self.type2test(u0)
uu1 = self.type2test(u1)
uu2 = self.type2test(u2)
Reported by Pylint.
Line: 112
Column: 14
u1 = self.type2test(l1)
u2 = self.type2test(l2)
uu = self.type2test(u)
uu0 = self.type2test(u0)
uu1 = self.type2test(u1)
uu2 = self.type2test(u2)
v = self.type2test(tuple(u))
Reported by Pylint.
Line: 113
Column: 15
u2 = self.type2test(l2)
uu = self.type2test(u)
uu0 = self.type2test(u0)
uu1 = self.type2test(u1)
uu2 = self.type2test(u2)
v = self.type2test(tuple(u))
class OtherSeq:
Reported by Pylint.
Line: 114
Column: 15
uu = self.type2test(u)
uu0 = self.type2test(u0)
uu1 = self.type2test(u1)
uu2 = self.type2test(u2)
v = self.type2test(tuple(u))
class OtherSeq:
def __init__(self, initseq):
Reported by Pylint.
Line: 115
Column: 15
uu = self.type2test(u)
uu0 = self.type2test(u0)
uu1 = self.type2test(u1)
uu2 = self.type2test(u2)
v = self.type2test(tuple(u))
class OtherSeq:
def __init__(self, initseq):
self.__data = initseq
Reported by Pylint.
Line: 117
Column: 13
uu1 = self.type2test(u1)
uu2 = self.type2test(u2)
v = self.type2test(tuple(u))
class OtherSeq:
def __init__(self, initseq):
self.__data = initseq
def __len__(self):
return len(self.__data)
Reported by Pylint.
Lib/test/test_httpservers.py
219 issues
Line: 661
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b103_set_bad_file_permissions.html
self.nocgi_path = os.path.join(self.parent_dir, 'nocgi.py')
with open(self.nocgi_path, 'w', encoding='utf-8') as fp:
fp.write(cgi_file1 % self.pythonexe)
os.chmod(self.nocgi_path, 0o777)
self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
with open(self.file1_path, 'w', encoding='utf-8') as file1:
file1.write(cgi_file1 % self.pythonexe)
os.chmod(self.file1_path, 0o777)
Reported by Bandit.
Line: 666
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b103_set_bad_file_permissions.html
self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
with open(self.file1_path, 'w', encoding='utf-8') as file1:
file1.write(cgi_file1 % self.pythonexe)
os.chmod(self.file1_path, 0o777)
self.file2_path = os.path.join(self.cgi_dir, 'file2.py')
with open(self.file2_path, 'w', encoding='utf-8') as file2:
file2.write(cgi_file2 % self.pythonexe)
os.chmod(self.file2_path, 0o777)
Reported by Bandit.
Line: 671
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b103_set_bad_file_permissions.html
self.file2_path = os.path.join(self.cgi_dir, 'file2.py')
with open(self.file2_path, 'w', encoding='utf-8') as file2:
file2.write(cgi_file2 % self.pythonexe)
os.chmod(self.file2_path, 0o777)
self.file3_path = os.path.join(self.cgi_child_dir, 'file3.py')
with open(self.file3_path, 'w', encoding='utf-8') as file3:
file3.write(cgi_file1 % self.pythonexe)
os.chmod(self.file3_path, 0o777)
Reported by Bandit.
Line: 676
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b103_set_bad_file_permissions.html
self.file3_path = os.path.join(self.cgi_child_dir, 'file3.py')
with open(self.file3_path, 'w', encoding='utf-8') as file3:
file3.write(cgi_file1 % self.pythonexe)
os.chmod(self.file3_path, 0o777)
self.file4_path = os.path.join(self.cgi_dir, 'file4.py')
with open(self.file4_path, 'w', encoding='utf-8') as file4:
file4.write(cgi_file4 % (self.pythonexe, 'QUERY_STRING'))
os.chmod(self.file4_path, 0o777)
Reported by Bandit.
Line: 681
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b103_set_bad_file_permissions.html
self.file4_path = os.path.join(self.cgi_dir, 'file4.py')
with open(self.file4_path, 'w', encoding='utf-8') as file4:
file4.write(cgi_file4 % (self.pythonexe, 'QUERY_STRING'))
os.chmod(self.file4_path, 0o777)
self.file5_path = os.path.join(self.cgi_dir_in_sub_dir, 'file5.py')
with open(self.file5_path, 'w', encoding='utf-8') as file5:
file5.write(cgi_file1 % self.pythonexe)
os.chmod(self.file5_path, 0o777)
Reported by Bandit.
Line: 686
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b103_set_bad_file_permissions.html
self.file5_path = os.path.join(self.cgi_dir_in_sub_dir, 'file5.py')
with open(self.file5_path, 'w', encoding='utf-8') as file5:
file5.write(cgi_file1 % self.pythonexe)
os.chmod(self.file5_path, 0o777)
self.file6_path = os.path.join(self.cgi_dir, 'file6.py')
with open(self.file6_path, 'w', encoding='utf-8') as file6:
file6.write(cgi_file6 % self.pythonexe)
os.chmod(self.file6_path, 0o777)
Reported by Bandit.
Line: 691
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b103_set_bad_file_permissions.html
self.file6_path = os.path.join(self.cgi_dir, 'file6.py')
with open(self.file6_path, 'w', encoding='utf-8') as file6:
file6.write(cgi_file6 % self.pythonexe)
os.chmod(self.file6_path, 0o777)
os.chdir(self.parent_dir)
def tearDown(self):
try:
Reported by Bandit.
Line: 72
Column: 46
self._threads = threading_helper.threading_setup()
os.environ = os_helper.EnvironmentVarGuard()
self.server_started = threading.Event()
self.thread = TestServerThread(self, self.request_handler)
self.thread.start()
self.server_started.wait()
def tearDown(self):
self.thread.stop()
Reported by Pylint.
Line: 83
Column: 65
threading_helper.threading_cleanup(*self._threads)
def request(self, uri, method='GET', body=None, headers={}):
self.connection = http.client.HTTPConnection(self.HOST, self.PORT)
self.connection.request(method, uri, body, headers)
return self.connection.getresponse()
class BaseHTTPServerTestCase(BaseTestCase):
Reported by Pylint.
Line: 83
Column: 54
threading_helper.threading_cleanup(*self._threads)
def request(self, uri, method='GET', body=None, headers={}):
self.connection = http.client.HTTPConnection(self.HOST, self.PORT)
self.connection.request(method, uri, body, headers)
return self.connection.getresponse()
class BaseHTTPServerTestCase(BaseTestCase):
Reported by Pylint.
Lib/idlelib/debugger.py
217 issues
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Line: 4
Column: 1
import bdb
import os
from tkinter import *
from tkinter.ttk import Frame, Scrollbar
from idlelib import macosx
from idlelib.scrolledlist import ScrolledList
from idlelib.window import ListedToplevel
Reported by Pylint.
Lib/unittest/test/testmock/testasync.py
217 issues
Line: 9
Column: 1
from contextlib import contextmanager
from asyncio import run, iscoroutinefunction
from unittest import IsolatedAsyncioTestCase
from unittest.mock import (ANY, call, AsyncMock, patch, MagicMock, Mock,
create_autospec, sentinel, _CallList)
def tearDownModule():
Reported by Pylint.
Line: 61
Column: 9
@patch.object(AsyncClass, 'async_method')
def test_async(mock_method):
self.assertTrue(iscoroutinefunction(mock_method))
test_async()
def test_is_async_patch(self):
@patch.object(AsyncClass, 'async_method')
def test_async(mock_method):
m = mock_method()
Reported by Pylint.
Line: 76
Column: 9
self.assertTrue(inspect.isawaitable(m))
run(m)
test_async()
test_no_parent_attribute()
def test_is_AsyncMock_patch(self):
@patch.object(AsyncClass, 'async_method')
def test_async(mock_method):
Reported by Pylint.
Line: 77
Column: 9
run(m)
test_async()
test_no_parent_attribute()
def test_is_AsyncMock_patch(self):
@patch.object(AsyncClass, 'async_method')
def test_async(mock_method):
self.assertIsInstance(mock_method, AsyncMock)
Reported by Pylint.
Line: 84
Column: 9
def test_async(mock_method):
self.assertIsInstance(mock_method, AsyncMock)
test_async()
def test_is_AsyncMock_patch_staticmethod(self):
@patch.object(AsyncClass, 'async_static_method')
def test_async(mock_method):
self.assertIsInstance(mock_method, AsyncMock)
Reported by Pylint.
Line: 91
Column: 9
def test_async(mock_method):
self.assertIsInstance(mock_method, AsyncMock)
test_async()
def test_is_AsyncMock_patch_classmethod(self):
@patch.object(AsyncClass, 'async_class_method')
def test_async(mock_method):
self.assertIsInstance(mock_method, AsyncMock)
Reported by Pylint.
Line: 98
Column: 9
def test_async(mock_method):
self.assertIsInstance(mock_method, AsyncMock)
test_async()
def test_async_def_patch(self):
@patch(f"{__name__}.async_func", return_value=1)
@patch(f"{__name__}.async_func_args", return_value=2)
async def test_async(func_args_mock, func_mock):
Reported by Pylint.
Line: 113
Column: 13
self.assertEqual(await async_func(), 1)
self.assertEqual(await async_func_args(1, 2, c=3), 2)
run(test_async())
self.assertTrue(inspect.iscoroutinefunction(async_func))
class AsyncPatchCMTest(unittest.TestCase):
def test_is_async_function_cm(self):
Reported by Pylint.
Line: 113
Column: 13
self.assertEqual(await async_func(), 1)
self.assertEqual(await async_func_args(1, 2, c=3), 2)
run(test_async())
self.assertTrue(inspect.iscoroutinefunction(async_func))
class AsyncPatchCMTest(unittest.TestCase):
def test_is_async_function_cm(self):
Reported by Pylint.
Line: 194
Column: 9
def test_normal_method(mock_method):
self.assertIsInstance(mock_method.normal_method, MagicMock)
test_async()
test_normal_method()
def test_create_autospec_instance(self):
with self.assertRaises(RuntimeError):
create_autospec(async_func, instance=True)
Reported by Pylint.
Lib/test/test_float.py
215 issues
Line: 11
Column: 1
import unittest
from test import support
from test.test_grammar import (VALID_UNDERSCORE_LITERALS,
INVALID_UNDERSCORE_LITERALS)
from math import isinf, isnan, copysign, ldexp
INF = float("inf")
NAN = float("nan")
Reported by Pylint.
Line: 11
Column: 1
import unittest
from test import support
from test.test_grammar import (VALID_UNDERSCORE_LITERALS,
INVALID_UNDERSCORE_LITERALS)
from math import isinf, isnan, copysign, ldexp
INF = float("inf")
NAN = float("nan")
Reported by Pylint.
Line: 319
Column: 31
self.assertEqual((a, copysign(1.0, a)), (b, copysign(1.0, b)))
def test_float_floor(self):
self.assertIsInstance(float(0.5).__floor__(), int)
self.assertEqual(float(0.5).__floor__(), 0)
self.assertEqual(float(1.0).__floor__(), 1)
self.assertEqual(float(1.5).__floor__(), 1)
self.assertEqual(float(-0.5).__floor__(), -1)
self.assertEqual(float(-1.0).__floor__(), -1)
Reported by Pylint.
Line: 320
Column: 26
def test_float_floor(self):
self.assertIsInstance(float(0.5).__floor__(), int)
self.assertEqual(float(0.5).__floor__(), 0)
self.assertEqual(float(1.0).__floor__(), 1)
self.assertEqual(float(1.5).__floor__(), 1)
self.assertEqual(float(-0.5).__floor__(), -1)
self.assertEqual(float(-1.0).__floor__(), -1)
self.assertEqual(float(-1.5).__floor__(), -2)
Reported by Pylint.
Line: 321
Column: 26
def test_float_floor(self):
self.assertIsInstance(float(0.5).__floor__(), int)
self.assertEqual(float(0.5).__floor__(), 0)
self.assertEqual(float(1.0).__floor__(), 1)
self.assertEqual(float(1.5).__floor__(), 1)
self.assertEqual(float(-0.5).__floor__(), -1)
self.assertEqual(float(-1.0).__floor__(), -1)
self.assertEqual(float(-1.5).__floor__(), -2)
self.assertEqual(float(1.23e167).__floor__(), 1.23e167)
Reported by Pylint.
Line: 322
Column: 26
self.assertIsInstance(float(0.5).__floor__(), int)
self.assertEqual(float(0.5).__floor__(), 0)
self.assertEqual(float(1.0).__floor__(), 1)
self.assertEqual(float(1.5).__floor__(), 1)
self.assertEqual(float(-0.5).__floor__(), -1)
self.assertEqual(float(-1.0).__floor__(), -1)
self.assertEqual(float(-1.5).__floor__(), -2)
self.assertEqual(float(1.23e167).__floor__(), 1.23e167)
self.assertEqual(float(-1.23e167).__floor__(), -1.23e167)
Reported by Pylint.
Line: 323
Column: 26
self.assertEqual(float(0.5).__floor__(), 0)
self.assertEqual(float(1.0).__floor__(), 1)
self.assertEqual(float(1.5).__floor__(), 1)
self.assertEqual(float(-0.5).__floor__(), -1)
self.assertEqual(float(-1.0).__floor__(), -1)
self.assertEqual(float(-1.5).__floor__(), -2)
self.assertEqual(float(1.23e167).__floor__(), 1.23e167)
self.assertEqual(float(-1.23e167).__floor__(), -1.23e167)
self.assertRaises(ValueError, float("nan").__floor__)
Reported by Pylint.
Line: 324
Column: 26
self.assertEqual(float(1.0).__floor__(), 1)
self.assertEqual(float(1.5).__floor__(), 1)
self.assertEqual(float(-0.5).__floor__(), -1)
self.assertEqual(float(-1.0).__floor__(), -1)
self.assertEqual(float(-1.5).__floor__(), -2)
self.assertEqual(float(1.23e167).__floor__(), 1.23e167)
self.assertEqual(float(-1.23e167).__floor__(), -1.23e167)
self.assertRaises(ValueError, float("nan").__floor__)
self.assertRaises(OverflowError, float("inf").__floor__)
Reported by Pylint.
Line: 325
Column: 26
self.assertEqual(float(1.5).__floor__(), 1)
self.assertEqual(float(-0.5).__floor__(), -1)
self.assertEqual(float(-1.0).__floor__(), -1)
self.assertEqual(float(-1.5).__floor__(), -2)
self.assertEqual(float(1.23e167).__floor__(), 1.23e167)
self.assertEqual(float(-1.23e167).__floor__(), -1.23e167)
self.assertRaises(ValueError, float("nan").__floor__)
self.assertRaises(OverflowError, float("inf").__floor__)
self.assertRaises(OverflowError, float("-inf").__floor__)
Reported by Pylint.
Line: 326
Column: 26
self.assertEqual(float(-0.5).__floor__(), -1)
self.assertEqual(float(-1.0).__floor__(), -1)
self.assertEqual(float(-1.5).__floor__(), -2)
self.assertEqual(float(1.23e167).__floor__(), 1.23e167)
self.assertEqual(float(-1.23e167).__floor__(), -1.23e167)
self.assertRaises(ValueError, float("nan").__floor__)
self.assertRaises(OverflowError, float("inf").__floor__)
self.assertRaises(OverflowError, float("-inf").__floor__)
Reported by Pylint.
Lib/unittest/case.py
213 issues
Line: 11
Column: 1
import warnings
import collections
import contextlib
import traceback
import types
from . import result
from .util import (strclass, safe_repr, _count_diff_all_purpose,
_count_diff_hashable, _common_shorten_repr)
Reported by Pylint.
Line: 14
Column: 1
import traceback
import types
from . import result
from .util import (strclass, safe_repr, _count_diff_all_purpose,
_count_diff_hashable, _common_shorten_repr)
__unittest = True
Reported by Pylint.
Line: 15
Column: 1
import types
from . import result
from .util import (strclass, safe_repr, _count_diff_all_purpose,
_count_diff_hashable, _common_shorten_repr)
__unittest = True
_subtest_msg_sentinel = object()
Reported by Pylint.
Line: 162
Column: 45
self.test_case = test_case
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
raise self.test_case.failureException(msg)
class _AssertRaisesBaseContext(_BaseTestCaseContext):
def __init__(self, expected, test_case, expected_regex=None):
Reported by Pylint.
Line: 185
Column: 47
arguments.
"""
try:
if not _is_subtype(self.expected, self._base_type):
raise TypeError('%s() arg 1 must be %s' %
(name, self._base_type_str))
if not args:
self.msg = kwargs.pop('msg', None)
if kwargs:
Reported by Pylint.
Line: 187
Column: 40
try:
if not _is_subtype(self.expected, self._base_type):
raise TypeError('%s() arg 1 must be %s' %
(name, self._base_type_str))
if not args:
self.msg = kwargs.pop('msg', None)
if kwargs:
raise TypeError('%r is an invalid keyword argument for '
'this function' % (next(iter(kwargs)),))
Reported by Pylint.
Line: 200
Column: 13
self.obj_name = callable_obj.__name__
except AttributeError:
self.obj_name = str(callable_obj)
with self:
callable_obj(*args, **kwargs)
finally:
# bpo-23890: manually break a reference cycle
self = None
Reported by Pylint.
Line: 617
Column: 21
if orig_result is None:
stopTestRun = getattr(result, 'stopTestRun', None)
if stopTestRun is not None:
stopTestRun()
# explicitly break reference cycles:
# outcome.errors -> frame -> outcome -> outcome.errors
# outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure
outcome.errors.clear()
Reported by Pylint.
Line: 791
Column: 9
'ERROR:foo.bar:second message'])
"""
# Lazy import to avoid importing logging if it is not needed.
from ._log import _AssertLogsContext
return _AssertLogsContext(self, logger, level, no_logs=False)
def assertNoLogs(self, logger=None, level=None):
""" Fail unless no log messages of level *level* or higher are emitted
on *logger_name* or its children.
Reported by Pylint.
Line: 800
Column: 9
This method must be used as a context manager.
"""
from ._log import _AssertLogsContext
return _AssertLogsContext(self, logger, level, no_logs=True)
def _getAssertEqualityFunc(self, first, second):
"""Get a detailed comparison function for the types of the two args.
Reported by Pylint.