The following issues were found
Lib/test/test_asyncio/test_runners.py
25 issues
Line: 5
Column: 1
import unittest
from unittest import mock
from . import utils as test_utils
class TestPolicy(asyncio.AbstractEventLoopPolicy):
def __init__(self, loop_factory):
Reported by Pylint.
Line: 8
Column: 1
from . import utils as test_utils
class TestPolicy(asyncio.AbstractEventLoopPolicy):
def __init__(self, loop_factory):
self.loop_factory = loop_factory
self.loop = None
Reported by Pylint.
Line: 8
Column: 1
from . import utils as test_utils
class TestPolicy(asyncio.AbstractEventLoopPolicy):
def __init__(self, loop_factory):
self.loop_factory = loop_factory
self.loop = None
Reported by Pylint.
Line: 32
Column: 9
def new_loop(self):
loop = asyncio.BaseEventLoop()
loop._process_events = mock.Mock()
loop._selector = mock.Mock()
loop._selector.select.return_value = ()
loop.shutdown_ag_run = False
async def shutdown_asyncgens():
Reported by Pylint.
Line: 33
Column: 9
def new_loop(self):
loop = asyncio.BaseEventLoop()
loop._process_events = mock.Mock()
loop._selector = mock.Mock()
loop._selector.select.return_value = ()
loop.shutdown_ag_run = False
async def shutdown_asyncgens():
loop.shutdown_ag_run = True
Reported by Pylint.
Line: 34
Column: 9
loop = asyncio.BaseEventLoop()
loop._process_events = mock.Mock()
loop._selector = mock.Mock()
loop._selector.select.return_value = ()
loop.shutdown_ag_run = False
async def shutdown_asyncgens():
loop.shutdown_ag_run = True
loop.shutdown_asyncgens = shutdown_asyncgens
Reported by Pylint.
Line: 128
Column: 17
try:
await asyncio.sleep(0.1)
except asyncio.CancelledError:
1 / 0
async def main():
loop = asyncio.get_running_loop()
loop.call_exception_handler = call_exc_handler_mock
Reported by Pylint.
Line: 163
Column: 27
nonlocal spinner
spinner = fidget()
try:
async for the_meaning_of_life in spinner: # NoQA
pass
except asyncio.CancelledError:
1 / 0
async def main():
Reported by Pylint.
Line: 166
Column: 17
async for the_meaning_of_life in spinner: # NoQA
pass
except asyncio.CancelledError:
1 / 0
async def main():
loop = asyncio.get_running_loop()
loop.call_exception_handler = mock.Mock()
Reported by Pylint.
Line: 1
Column: 1
import asyncio
import unittest
from unittest import mock
from . import utils as test_utils
class TestPolicy(asyncio.AbstractEventLoopPolicy):
Reported by Pylint.
Tools/peg_generator/pegen/parser_generator.py
25 issues
Line: 115
Column: 3
def name_node(self, rhs: Rhs) -> str:
self.counter += 1
name = f"_tmp_{self.counter}" # TODO: Pick a nicer name.
self.todo[name] = Rule(name, None, rhs)
return name
def name_loop(self, node: Plain, is_repeat1: bool) -> str:
self.counter += 1
Reported by Pylint.
Line: 125
Column: 3
prefix = "_loop1_"
else:
prefix = "_loop0_"
name = f"{prefix}{self.counter}" # TODO: It's ugly to signal via the name.
self.todo[name] = Rule(name, None, Rhs([Alt([NamedItem(None, node)])]))
return name
def name_gather(self, node: Gather) -> str:
self.counter += 1
Reported by Pylint.
Line: 1
Column: 1
import contextlib
from abc import abstractmethod
from typing import IO, AbstractSet, Dict, Iterator, List, Optional, Set, Text, Tuple
from pegen import sccutils
from pegen.grammar import (
Alt,
Gather,
Grammar,
Reported by Pylint.
Line: 20
Column: 1
)
class RuleCheckingVisitor(GrammarVisitor):
def __init__(self, rules: Dict[str, Rule], tokens: Set[str]):
self.rules = rules
self.tokens = tokens
def visit_NameLeaf(self, node: NameLeaf) -> None:
Reported by Pylint.
Line: 25
Column: 5
self.rules = rules
self.tokens = tokens
def visit_NameLeaf(self, node: NameLeaf) -> None:
if node.value not in self.rules and node.value not in self.tokens:
raise GrammarError(f"Dangling reference to rule {node.value!r}")
def visit_NamedItem(self, node: NamedItem) -> None:
if node.name and node.name.startswith("_"):
Reported by Pylint.
Line: 25
Column: 5
self.rules = rules
self.tokens = tokens
def visit_NameLeaf(self, node: NameLeaf) -> None:
if node.value not in self.rules and node.value not in self.tokens:
raise GrammarError(f"Dangling reference to rule {node.value!r}")
def visit_NamedItem(self, node: NamedItem) -> None:
if node.name and node.name.startswith("_"):
Reported by Pylint.
Line: 29
Column: 5
if node.value not in self.rules and node.value not in self.tokens:
raise GrammarError(f"Dangling reference to rule {node.value!r}")
def visit_NamedItem(self, node: NamedItem) -> None:
if node.name and node.name.startswith("_"):
raise GrammarError(f"Variable names cannot start with underscore: '{node.name}'")
self.visit(node.item)
Reported by Pylint.
Line: 29
Column: 5
if node.value not in self.rules and node.value not in self.tokens:
raise GrammarError(f"Dangling reference to rule {node.value!r}")
def visit_NamedItem(self, node: NamedItem) -> None:
if node.name and node.name.startswith("_"):
raise GrammarError(f"Variable names cannot start with underscore: '{node.name}'")
self.visit(node.item)
Reported by Pylint.
Line: 35
Column: 1
self.visit(node.item)
class ParserGenerator:
callmakervisitor: GrammarVisitor
def __init__(self, grammar: Grammar, tokens: Set[str], file: Optional[IO[Text]]):
self.grammar = grammar
Reported by Pylint.
Line: 35
Column: 1
self.visit(node.item)
class ParserGenerator:
callmakervisitor: GrammarVisitor
def __init__(self, grammar: Grammar, tokens: Set[str], file: Optional[IO[Text]]):
self.grammar = grammar
Reported by Pylint.
Tools/scripts/stable_abi.py
25 issues
Line: 18
Column: 1
import argparse
import textwrap
import difflib
import shutil
import sys
import os
import os.path
import io
import re
Reported by Pylint.
Line: 47
Column: 3
"ucnhash.h",
}
MACOS = (sys.platform == "darwin")
UNIXY = MACOS or (sys.platform == "linux") # XXX should this be "not Windows"?
IFDEF_DOC_NOTES = {
'MS_WINDOWS': 'on Windows',
'HAVE_FORK': 'on platforms with fork()',
'USE_STACKCHECK': 'on platforms with USE_STACKCHECK',
Reported by Pylint.
Line: 95
Column: 13
different from the empty set, which filters out all such
conditional items.)
"""
for name, item in sorted(self.contents.items()):
if item.kind not in kinds:
continue
if item.abi_only and not include_abi_only:
continue
if (ifdef is not None
Reported by Pylint.
Line: 146
Column: 35
levels = [(manifest, -1)]
def raise_error(msg):
raise SyntaxError(f'line {lineno}: {msg}')
for lineno, line in enumerate(file, start=1):
line, sep, comment = line.partition('#')
line = line.rstrip()
if not line:
Reported by Pylint.
Line: 149
Column: 15
raise SyntaxError(f'line {lineno}: {msg}')
for lineno, line in enumerate(file, start=1):
line, sep, comment = line.partition('#')
line = line.rstrip()
if not line:
continue
match = LINE_RE.fullmatch(line)
if not match:
Reported by Pylint.
Line: 149
Column: 20
raise SyntaxError(f'line {lineno}: {msg}')
for lineno, line in enumerate(file, start=1):
line, sep, comment = line.partition('#')
line = line.rstrip()
if not line:
continue
match = LINE_RE.fullmatch(line)
if not match:
Reported by Pylint.
Line: 175
Column: 13
elif kind in {'abi_only'}:
if parent.kind not in {'function', 'data'}:
raise_error(f'{kind} cannot go in {parent.kind}')
parent.abi_only = True
else:
raise_error(f"unknown kind {kind!r}")
levels.append((entry, level))
return manifest
Reported by Pylint.
Line: 199
Column: 30
@generator("python3dll", 'PC/python3dll.c')
def gen_python3dll(manifest, args, outfile):
"""Generate/check the source for the Windows stable ABI library"""
write = partial(print, file=outfile)
write(textwrap.dedent(r"""
/* Re-export stable Python ABI */
Reported by Pylint.
Line: 246
Column: 35
}
@generator("doc_list", 'Doc/data/stable_abi.dat')
def gen_doc_annotations(manifest, args, outfile):
"""Generate/check the stable ABI list for documentation annotations"""
writer = csv.DictWriter(
outfile, ['role', 'name', 'added', 'ifdef_note'], lineterminator='\n')
writer.writeheader()
for item in manifest.select(REST_ROLES.keys(), include_abi_only=False):
Reported by Pylint.
Line: 289
Column: 30
return True
def do_unixy_check(manifest, args):
"""Check headers & library using "Unixy" tools (GCC/clang, binutils)"""
okay = True
# Get all macros first: we'll need feature macros like HAVE_FORK and
# MS_WINDOWS for everything else
Reported by Pylint.
Lib/test/test_structmembers.py
25 issues
Line: 1
Column: 1
import unittest
from test.support import import_helper
from test.support import warnings_helper
# Skip this test if the _testcapi module isn't available.
import_helper.import_module('_testcapi')
from _testcapi import _test_structmembersType, \
CHAR_MAX, CHAR_MIN, UCHAR_MAX, \
SHRT_MAX, SHRT_MIN, USHRT_MAX, \
Reported by Pylint.
Line: 7
Column: 1
# Skip this test if the _testcapi module isn't available.
import_helper.import_module('_testcapi')
from _testcapi import _test_structmembersType, \
CHAR_MAX, CHAR_MIN, UCHAR_MAX, \
SHRT_MAX, SHRT_MIN, USHRT_MAX, \
INT_MAX, INT_MIN, UINT_MAX, \
LONG_MAX, LONG_MIN, ULONG_MAX, \
LLONG_MAX, LLONG_MIN, ULLONG_MAX, \
Reported by Pylint.
Line: 30
Column: 1
"hi" # T_STRING_INPLACE
)
class ReadWriteTests(unittest.TestCase):
def test_bool(self):
ts.T_BOOL = True
self.assertEqual(ts.T_BOOL, True)
ts.T_BOOL = False
Reported by Pylint.
Line: 32
Column: 5
class ReadWriteTests(unittest.TestCase):
def test_bool(self):
ts.T_BOOL = True
self.assertEqual(ts.T_BOOL, True)
ts.T_BOOL = False
self.assertEqual(ts.T_BOOL, False)
self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)
Reported by Pylint.
Line: 39
Column: 5
self.assertEqual(ts.T_BOOL, False)
self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)
def test_byte(self):
ts.T_BYTE = CHAR_MAX
self.assertEqual(ts.T_BYTE, CHAR_MAX)
ts.T_BYTE = CHAR_MIN
self.assertEqual(ts.T_BYTE, CHAR_MIN)
ts.T_UBYTE = UCHAR_MAX
Reported by Pylint.
Line: 47
Column: 5
ts.T_UBYTE = UCHAR_MAX
self.assertEqual(ts.T_UBYTE, UCHAR_MAX)
def test_short(self):
ts.T_SHORT = SHRT_MAX
self.assertEqual(ts.T_SHORT, SHRT_MAX)
ts.T_SHORT = SHRT_MIN
self.assertEqual(ts.T_SHORT, SHRT_MIN)
ts.T_USHORT = USHRT_MAX
Reported by Pylint.
Line: 55
Column: 5
ts.T_USHORT = USHRT_MAX
self.assertEqual(ts.T_USHORT, USHRT_MAX)
def test_int(self):
ts.T_INT = INT_MAX
self.assertEqual(ts.T_INT, INT_MAX)
ts.T_INT = INT_MIN
self.assertEqual(ts.T_INT, INT_MIN)
ts.T_UINT = UINT_MAX
Reported by Pylint.
Line: 63
Column: 5
ts.T_UINT = UINT_MAX
self.assertEqual(ts.T_UINT, UINT_MAX)
def test_long(self):
ts.T_LONG = LONG_MAX
self.assertEqual(ts.T_LONG, LONG_MAX)
ts.T_LONG = LONG_MIN
self.assertEqual(ts.T_LONG, LONG_MIN)
ts.T_ULONG = ULONG_MAX
Reported by Pylint.
Line: 71
Column: 5
ts.T_ULONG = ULONG_MAX
self.assertEqual(ts.T_ULONG, ULONG_MAX)
def test_py_ssize_t(self):
ts.T_PYSSIZET = PY_SSIZE_T_MAX
self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MAX)
ts.T_PYSSIZET = PY_SSIZE_T_MIN
self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MIN)
Reported by Pylint.
Line: 78
Column: 5
self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MIN)
@unittest.skipUnless(hasattr(ts, "T_LONGLONG"), "long long not present")
def test_longlong(self):
ts.T_LONGLONG = LLONG_MAX
self.assertEqual(ts.T_LONGLONG, LLONG_MAX)
ts.T_LONGLONG = LLONG_MIN
self.assertEqual(ts.T_LONGLONG, LLONG_MIN)
Reported by Pylint.
Modules/_ctypes/cfield.c
25 issues
Line: 521
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
return NULL;
memcpy(&x, ptr, sizeof(x));
x = SET(short, x, val, size);
memcpy(ptr, &x, sizeof(x));
_RET(value);
}
static PyObject *
Reported by FlawFinder.
Line: 538
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
field = SWAP_SHORT(field);
field = SET(short, field, val, size);
field = SWAP_SHORT(field);
memcpy(ptr, &field, sizeof(field));
_RET(value);
}
static PyObject *
h_get(void *ptr, Py_ssize_t size)
Reported by FlawFinder.
Line: 570
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
return NULL;
memcpy(&x, ptr, sizeof(x));
x = SET(unsigned short, x, val, size);
memcpy(ptr, &x, sizeof(x));
_RET(value);
}
static PyObject *
H_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
Reported by FlawFinder.
Line: 586
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
field = SWAP_SHORT(field);
field = SET(unsigned short, field, val, size);
field = SWAP_SHORT(field);
memcpy(ptr, &field, sizeof(field));
_RET(value);
}
static PyObject *
Reported by FlawFinder.
Line: 619
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
return NULL;
memcpy(&x, ptr, sizeof(x));
x = SET(int, x, val, size);
memcpy(ptr, &x, sizeof(x));
_RET(value);
}
static PyObject *
i_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
Reported by FlawFinder.
Line: 635
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
field = SWAP_INT(field);
field = SET(int, field, val, size);
field = SWAP_INT(field);
memcpy(ptr, &field, sizeof(field));
_RET(value);
}
static PyObject *
Reported by FlawFinder.
Line: 716
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
return NULL;
memcpy(&x, ptr, sizeof(x));
x = SET(unsigned int, x, val, size);
memcpy(ptr, &x, sizeof(x));
_RET(value);
}
static PyObject *
I_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
Reported by FlawFinder.
Line: 732
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
field = SWAP_INT(field);
field = SET(unsigned int, field, (unsigned int)val, size);
field = SWAP_INT(field);
memcpy(ptr, &field, sizeof(field));
_RET(value);
}
static PyObject *
Reported by FlawFinder.
Line: 765
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
return NULL;
memcpy(&x, ptr, sizeof(x));
x = SET(long, x, val, size);
memcpy(ptr, &x, sizeof(x));
_RET(value);
}
static PyObject *
l_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
Reported by FlawFinder.
Line: 781
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
field = SWAP_LONG(field);
field = SET(long, field, val, size);
field = SWAP_LONG(field);
memcpy(ptr, &field, sizeof(field));
_RET(value);
}
static PyObject *
Reported by FlawFinder.
Lib/test/test_popen.py
25 issues
Line: 27
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html
def _do_test_commandline(self, cmdline, expected):
cmd = '%s -c "import sys; print(sys.argv)" %s'
cmd = cmd % (python, cmdline)
with os.popen(cmd) as p:
data = p.read()
got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected)
def test_popen(self):
Reported by Bandit.
Line: 54
Column: 30
if os.name == 'nt':
self.assertEqual(status, 42)
else:
self.assertEqual(os.waitstatus_to_exitcode(status), 42)
def test_contextmanager(self):
with os.popen("echo hello") as f:
self.assertEqual(f.read(), "hello\n")
Reported by Pylint.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
cmd = cmd % (python, cmdline)
with os.popen(cmd) as p:
data = p.read()
got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected)
def test_popen(self):
self.assertRaises(TypeError, os.popen)
self._do_test_commandline(
Reported by Bandit.
Line: 29
Column: 15
cmd = cmd % (python, cmdline)
with os.popen(cmd) as p:
data = p.read()
got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected)
def test_popen(self):
self.assertRaises(TypeError, os.popen)
self._do_test_commandline(
Reported by Pylint.
Line: 8
Column: 1
import unittest
from test import support
import os, sys
if not hasattr(os, 'popen'):
raise unittest.SkipTest("need os.popen()")
# Test that command-lines get down as we expect.
Reported by Pylint.
Line: 18
Column: 1
# python -c "import sys;print(sys.argv)" {rest_of_commandline}
# This results in Python being spawned and printing the sys.argv list.
# We can then eval() the result of this, and see what each argv was.
python = sys.executable
if ' ' in python:
python = '"' + python + '"' # quote embedded space for cmdline
class PopenTest(unittest.TestCase):
Reported by Pylint.
Line: 20
Column: 5
# We can then eval() the result of this, and see what each argv was.
python = sys.executable
if ' ' in python:
python = '"' + python + '"' # quote embedded space for cmdline
class PopenTest(unittest.TestCase):
def _do_test_commandline(self, cmdline, expected):
cmd = '%s -c "import sys; print(sys.argv)" %s'
Reported by Pylint.
Line: 22
Column: 1
if ' ' in python:
python = '"' + python + '"' # quote embedded space for cmdline
class PopenTest(unittest.TestCase):
def _do_test_commandline(self, cmdline, expected):
cmd = '%s -c "import sys; print(sys.argv)" %s'
cmd = cmd % (python, cmdline)
with os.popen(cmd) as p:
Reported by Pylint.
Line: 27
Column: 31
def _do_test_commandline(self, cmdline, expected):
cmd = '%s -c "import sys; print(sys.argv)" %s'
cmd = cmd % (python, cmdline)
with os.popen(cmd) as p:
data = p.read()
got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected)
def test_popen(self):
Reported by Pylint.
Line: 32
Column: 5
got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected)
def test_popen(self):
self.assertRaises(TypeError, os.popen)
self._do_test_commandline(
"foo bar",
["foo", "bar"]
)
Reported by Pylint.
Tools/c-analyzer/c_analyzer/match.py
24 issues
Line: 141
Column: 12
def is_public_impl(decl):
if not _KIND.is_decl(decl.kind):
return False
# See filter_forward() about "is_public".
return getattr(decl, 'is_public', False)
Reported by Pylint.
Line: 12
Column: 3
_KIND = _info.KIND
# XXX Use known.tsv for these?
SYSTEM_TYPES = {
'int8_t',
'uint8_t',
'int16_t',
'uint16_t',
Reported by Pylint.
Line: 85
Column: 3
return True
if '*' not in abstract:
# XXX What about []?
return True
elif _match._is_funcptr(abstract):
return True
else:
for after in abstract.split('*')[1:]:
Reported by Pylint.
Line: 87
Column: 10
if '*' not in abstract:
# XXX What about []?
return True
elif _match._is_funcptr(abstract):
return True
else:
for after in abstract.split('*')[1:]:
if not after.lstrip().startswith('const'):
return False
Reported by Pylint.
Line: 93
Column: 9
for after in abstract.split('*')[1:]:
if not after.lstrip().startswith('const'):
return False
else:
return True
def is_immutable(vardecl):
if not vardecl:
Reported by Pylint.
Line: 169
Column: 3
actual.append(item)
else:
# non-public duplicate!
# XXX
raise Exception(item)
for item in actual:
_info.set_flag(item, 'is_public', item.id in public)
yield item
else:
Reported by Pylint.
Line: 1
Column: 1
import os.path
from c_parser import (
info as _info,
match as _match,
)
_KIND = _info.KIND
Reported by Pylint.
Line: 46
Column: 1
}
def is_system_type(typespec):
return typespec in SYSTEM_TYPES
##################################
# decl matchers
Reported by Pylint.
Line: 53
Column: 1
##################################
# decl matchers
def is_public(decl):
if not decl.filename.endswith('.h'):
return False
if 'Include' not in decl.filename.split(os.path.sep):
return False
return True
Reported by Pylint.
Line: 61
Column: 1
return True
def is_process_global(vardecl):
kind, storage, _, _, _ = _info.get_parsed_vartype(vardecl)
if kind is not _KIND.VARIABLE:
raise NotImplementedError(vardecl)
if 'static' in (storage or ''):
return True
Reported by Pylint.
Tools/c-analyzer/c_common/tables.py
24 issues
Line: 5
Column: 1
import re
import textwrap
from . import NOT_SET, strutil, fsutil
EMPTY = '-'
UNKNOWN = '???'
Reported by Pylint.
Line: 302
Column: 16
def _normalize_colspec(spec):
if len(spec) == 1:
raw, = spec
return _resolve_column(raw)
if len(spec) == 4:
label, field, width, fmt = spec
if width:
fmt = f'{width}:{fmt}' if fmt else width
Reported by Pylint.
Line: 55
Column: 9
if fix is None:
fix = ''
if callable(fix):
def fix_row(row):
values = fix(row)
return _fix_read_default(values)
elif isinstance(fix, str):
def fix_row(row):
values = _fix_read_default(row)
Reported by Pylint.
Line: 72
Column: 9
if fix is None:
fix = empty
if callable(fix):
def fix_row(row):
values = fix(row)
return _fix_write_default(values, empty)
elif isinstance(fix, str):
def fix_row(row):
return _fix_write_default(row, fix)
Reported by Pylint.
Line: 101
Column: 13
_get_reader=_get_reader,
)
return
lines = strutil._iter_significant_lines(infile)
# Validate the header.
if not isinstance(header, str):
header = sep.join(header)
try:
Reported by Pylint.
Line: 113
Column: 5
if actualheader != header:
raise ValueError(f'bad header {actualheader!r}')
fix_row = _normalize_fix_read(fix)
for row in _get_reader(lines, delimiter=sep or '\t'):
yield tuple(fix_row(row))
def write_table(outfile, header, rows, *,
Reported by Pylint.
Line: 143
Column: 5
if isinstance(header, str):
header = header.split(sep or '\t')
fix_row = _normalize_fix_write(fix)
writer = _get_writer(outfile, delimiter=sep or '\t')
writer.writerow(header)
for row in rows:
writer.writerow(
tuple(fix_row(row))
Reported by Pylint.
Line: 1
Column: 1
import csv
import re
import textwrap
from . import NOT_SET, strutil, fsutil
EMPTY = '-'
UNKNOWN = '???'
Reported by Pylint.
Line: 12
Column: 1
UNKNOWN = '???'
def parse_markers(markers, default=None):
if markers is NOT_SET:
return default
if not markers:
return None
if type(markers) is not str:
Reported by Pylint.
Line: 17
Column: 8
return default
if not markers:
return None
if type(markers) is not str:
return markers
if markers == markers[0] * len(markers):
return [markers]
return list(markers)
Reported by Pylint.
Lib/unittest/test/test_functiontestcase.py
24 issues
Line: 1
Column: 1
import unittest
from unittest.test.support import LoggingResult
class Test_FunctionTestCase(unittest.TestCase):
# "Return the number of tests represented by the this test object. For
# TestCase instances, this will always be 1"
Reported by Pylint.
Line: 6
Column: 1
from unittest.test.support import LoggingResult
class Test_FunctionTestCase(unittest.TestCase):
# "Return the number of tests represented by the this test object. For
# TestCase instances, this will always be 1"
def test_countTestCases(self):
test = unittest.FunctionTestCase(lambda: None)
Reported by Pylint.
Line: 6
Column: 1
from unittest.test.support import LoggingResult
class Test_FunctionTestCase(unittest.TestCase):
# "Return the number of tests represented by the this test object. For
# TestCase instances, this will always be 1"
def test_countTestCases(self):
test = unittest.FunctionTestCase(lambda: None)
Reported by Pylint.
Line: 10
Column: 5
# "Return the number of tests represented by the this test object. For
# TestCase instances, this will always be 1"
def test_countTestCases(self):
test = unittest.FunctionTestCase(lambda: None)
self.assertEqual(test.countTestCases(), 1)
# "When a setUp() method is defined, the test runner will run that method
Reported by Pylint.
Line: 10
Column: 5
# "Return the number of tests represented by the this test object. For
# TestCase instances, this will always be 1"
def test_countTestCases(self):
test = unittest.FunctionTestCase(lambda: None)
self.assertEqual(test.countTestCases(), 1)
# "When a setUp() method is defined, the test runner will run that method
Reported by Pylint.
Line: 22
Column: 5
#
# Make sure the proper call order is maintained, even if setUp() raises
# an exception.
def test_run_call_order__error_in_setUp(self):
events = []
result = LoggingResult(events)
def setUp():
events.append('setUp')
Reported by Pylint.
Line: 22
Column: 5
#
# Make sure the proper call order is maintained, even if setUp() raises
# an exception.
def test_run_call_order__error_in_setUp(self):
events = []
result = LoggingResult(events)
def setUp():
events.append('setUp')
Reported by Pylint.
Line: 26
Column: 9
events = []
result = LoggingResult(events)
def setUp():
events.append('setUp')
raise RuntimeError('raised by setUp')
def test():
events.append('test')
Reported by Pylint.
Line: 33
Column: 9
def test():
events.append('test')
def tearDown():
events.append('tearDown')
expected = ['startTest', 'setUp', 'addError', 'stopTest']
unittest.FunctionTestCase(test, setUp, tearDown).run(result)
self.assertEqual(events, expected)
Reported by Pylint.
Line: 47
Column: 5
#
# Make sure the proper call order is maintained, even if the test raises
# an error (as opposed to a failure).
def test_run_call_order__error_in_test(self):
events = []
result = LoggingResult(events)
def setUp():
events.append('setUp')
Reported by Pylint.
Lib/unittest/test/testmock/testcallable.py
24 issues
Line: 1
Column: 1
# Copyright (C) 2007-2012 Michael Foord & the mock team
# E-mail: fuzzyman AT voidspace DOT org DOT uk
# http://www.voidspace.org.uk/python/mock/
import unittest
from unittest.test.testmock.support import is_instance, X, SomeClass
from unittest.mock import (
Mock, MagicMock, NonCallableMagicMock,
Reported by Pylint.
Line: 16
Column: 1
class TestCallable(unittest.TestCase):
def assertNotCallable(self, mock):
self.assertTrue(is_instance(mock, NonCallableMagicMock))
self.assertFalse(is_instance(mock, CallableMixin))
Reported by Pylint.
Line: 18
Column: 5
class TestCallable(unittest.TestCase):
def assertNotCallable(self, mock):
self.assertTrue(is_instance(mock, NonCallableMagicMock))
self.assertFalse(is_instance(mock, CallableMixin))
def test_non_callable(self):
Reported by Pylint.
Line: 18
Column: 5
class TestCallable(unittest.TestCase):
def assertNotCallable(self, mock):
self.assertTrue(is_instance(mock, NonCallableMagicMock))
self.assertFalse(is_instance(mock, CallableMixin))
def test_non_callable(self):
Reported by Pylint.
Line: 23
Column: 5
self.assertFalse(is_instance(mock, CallableMixin))
def test_non_callable(self):
for mock in NonCallableMagicMock(), NonCallableMock():
self.assertRaises(TypeError, mock)
self.assertFalse(hasattr(mock, '__call__'))
self.assertIn(mock.__class__.__name__, repr(mock))
Reported by Pylint.
Line: 30
Column: 5
self.assertIn(mock.__class__.__name__, repr(mock))
def test_hierarchy(self):
self.assertTrue(issubclass(MagicMock, Mock))
self.assertTrue(issubclass(NonCallableMagicMock, NonCallableMock))
def test_attributes(self):
Reported by Pylint.
Line: 35
Column: 5
self.assertTrue(issubclass(NonCallableMagicMock, NonCallableMock))
def test_attributes(self):
one = NonCallableMock()
self.assertTrue(issubclass(type(one.one), Mock))
two = NonCallableMagicMock()
self.assertTrue(issubclass(type(two.two), MagicMock))
Reported by Pylint.
Line: 43
Column: 5
self.assertTrue(issubclass(type(two.two), MagicMock))
def test_subclasses(self):
class MockSub(Mock):
pass
one = MockSub()
self.assertTrue(issubclass(type(one.one), MockSub))
Reported by Pylint.
Line: 44
Column: 9
def test_subclasses(self):
class MockSub(Mock):
pass
one = MockSub()
self.assertTrue(issubclass(type(one.one), MockSub))
Reported by Pylint.
Line: 50
Column: 9
one = MockSub()
self.assertTrue(issubclass(type(one.one), MockSub))
class MagicSub(MagicMock):
pass
two = MagicSub()
self.assertTrue(issubclass(type(two.two), MagicSub))
Reported by Pylint.