Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 1 addition & 1 deletion src/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def message(self) -> str:

for f, lines in self._files or []:
assert type(f) is str
assert type(lines) in [str, bytes] # noqa: E721
assert type(lines) in [str, bytes]
msg.append(u'{}\n----\n{}\n'.format(f, lines))

return six.text_type('\n').join(msg)
Expand Down
2 changes: 1 addition & 1 deletion src/impl/port_manager__generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def reserve_port(self) -> int:
t = None

for port in sampled_ports:
assert type(port) is int # noqa: E721
assert type(port) is int
assert port not in self._reserved_ports
assert port in self._available_ports

Expand Down
2 changes: 1 addition & 1 deletion src/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2244,7 +2244,7 @@ def _table_checksum__use_cn(

row = cursor.fetchone()
assert row is not None
assert type(row) in [list, tuple] # noqa: E721
assert type(row) in [list, tuple]
assert len(row) == 1
v = row[0]
sum += int(v if v is not None else 0)
Expand Down
54 changes: 27 additions & 27 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class TestStartupData__Helper:
# --------------------------------------------------------------------
@staticmethod
def GetStartTS() -> datetime.datetime:
assert type(__class__.sm_StartTS) == datetime.datetime # noqa: E721
assert type(__class__.sm_StartTS) is datetime.datetime
return __class__.sm_StartTS

# --------------------------------------------------------------------
Expand Down Expand Up @@ -113,7 +113,7 @@ def CalcCurrentTestWorkerSignature() -> str:
assert type(currentPID) is int

startTS = __class__.sm_StartTS
assert type(startTS) == datetime.datetime # noqa: E721
assert type(startTS) is datetime.datetime

result = "pytest-{0:04d}{1:02d}{2:02d}_{3:02d}{4:02d}{5:02d}".format(
startTS.year,
Expand Down Expand Up @@ -405,8 +405,8 @@ def helper__makereport__setup(
assert outcome is not None
# it may be pytest.Function or _pytest.unittest.TestCaseFunction
assert isinstance(item, pytest.Function)
assert type(call) == pytest.CallInfo # noqa: E721
assert type(outcome) == T_PLUGGY_RESULT # noqa: E721
assert type(call) is pytest.CallInfo
assert type(outcome) is T_PLUGGY_RESULT

C_LINE1 = "******************************************************"

Expand All @@ -416,7 +416,7 @@ def helper__makereport__setup(

rep: pytest.TestReport = outcome.get_result()
assert rep is not None
assert type(rep) == pytest.TestReport # noqa: E721
assert type(rep) is pytest.TestReport

if rep.outcome == "skipped":
TEST_PROCESS_STATS.incrementNotExecutedTestCount()
Expand Down Expand Up @@ -474,8 +474,8 @@ def helper__makereport__call(
assert outcome is not None
# it may be pytest.Function or _pytest.unittest.TestCaseFunction
assert isinstance(item, pytest.Function)
assert type(call) == pytest.CallInfo # noqa: E721
assert type(outcome) == T_PLUGGY_RESULT # noqa: E721
assert type(call) is pytest.CallInfo
assert type(outcome) is T_PLUGGY_RESULT

# --------
item_error_msg_count1 = item.stash.get(g_error_msg_count_key, 0)
Expand All @@ -496,7 +496,7 @@ def helper__makereport__call(
# --------
rep = outcome.get_result()
assert rep is not None
assert type(rep) == pytest.TestReport # noqa: E721
assert type(rep) is pytest.TestReport

# --------
testID = helper__build_test_id(item)
Expand All @@ -505,12 +505,12 @@ def helper__makereport__call(
assert call.start <= call.stop

startDT = datetime.datetime.fromtimestamp(call.start)
assert type(startDT) == datetime.datetime # noqa: E721
assert type(startDT) is datetime.datetime
stopDT = datetime.datetime.fromtimestamp(call.stop)
assert type(stopDT) == datetime.datetime # noqa: E721
assert type(stopDT) is datetime.datetime

testDurration = stopDT - startDT
assert type(testDurration) == datetime.timedelta # noqa: E721
assert type(testDurration) is datetime.timedelta

# --------
exitStatus = None
Expand All @@ -519,7 +519,7 @@ def helper__makereport__call(
assert call.excinfo is not None # research
assert call.excinfo.value is not None # research

if type(call.excinfo.value) == _pytest.outcomes.Skipped: # noqa: E721
if type(call.excinfo.value) is _pytest.outcomes.Skipped:
assert not hasattr(rep, "wasxfail")

exitStatus = ExitStatusNames.SKIPPED
Expand All @@ -528,7 +528,7 @@ def helper__makereport__call(

TEST_PROCESS_STATS.incrementSkippedTestCount()

elif type(call.excinfo.value) == _pytest.outcomes.XFailed: # noqa: E721 E501
elif type(call.excinfo.value) is _pytest.outcomes.XFailed:
exitStatus = ExitStatusNames.XFAILED
reasonText = str(call.excinfo.value)
reasonMsgTempl = "XFAIL REASON: {0}"
Expand All @@ -544,7 +544,7 @@ def helper__makereport__call(
reasonText = rep.wasxfail
reasonMsgTempl = "XFAIL REASON: {0}"

if type(call.excinfo.value) == SIGNAL_EXCEPTION: # noqa: E721
if type(call.excinfo.value) is SIGNAL_EXCEPTION:
pass
else:
logging.error(call.excinfo.value)
Expand All @@ -563,7 +563,7 @@ def helper__makereport__call(
assert call.excinfo is not None
assert call.excinfo.value is not None

if type(call.excinfo.value) == SIGNAL_EXCEPTION: # noqa: E721
if type(call.excinfo.value) is SIGNAL_EXCEPTION:
assert item_error_msg_count > 0
pass
else:
Expand Down Expand Up @@ -614,8 +614,8 @@ def helper__makereport__call(
pass

# --------
assert type(TEST_PROCESS_STATS.cTotalDuration) == datetime.timedelta # noqa: E721
assert type(testDurration) == datetime.timedelta # noqa: E721
assert type(TEST_PROCESS_STATS.cTotalDuration) is datetime.timedelta
assert type(testDurration) is datetime.timedelta

TEST_PROCESS_STATS.cTotalDuration += testDurration

Expand Down Expand Up @@ -656,11 +656,11 @@ def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo):
assert call is not None
# it may be pytest.Function or _pytest.unittest.TestCaseFunction
assert isinstance(item, pytest.Function)
assert type(call) == pytest.CallInfo # noqa: E721
assert type(call) is pytest.CallInfo

outcome = yield
assert outcome is not None
assert type(outcome) == T_PLUGGY_RESULT # noqa: E721
assert type(outcome) is T_PLUGGY_RESULT

assert type(call.when) is str

Expand Down Expand Up @@ -808,7 +808,7 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function):

try:
with LogWrapper2() as logWrapper:
assert type(logWrapper) == LogWrapper2 # noqa: E721
assert type(logWrapper) is LogWrapper2
assert logWrapper._old_method is not None
assert type(logWrapper._err_counter) is int
assert logWrapper._err_counter == 0
Expand All @@ -821,7 +821,7 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function):
r = yield

assert r is not None
assert type(r) == T_PLUGGY_RESULT # noqa: E721
assert type(r) is T_PLUGGY_RESULT

assert logWrapper._old_method is not None
assert type(logWrapper._err_counter) is int
Expand Down Expand Up @@ -918,7 +918,7 @@ def helper__print_test_list2(tests: typing.List[T_TUPLE__str_int]) -> None:
nTest = 0

for t in tests:
assert type(t) == tuple # noqa: E721
assert type(t) is tuple
assert len(t) == 2
assert type(t[0]) is str
assert type(t[1]) is int
Expand All @@ -943,15 +943,15 @@ def pytest_sessionfinish():
global g_worker_log_is_created # noqa: F824

assert g_test_process_kind is not None
assert type(g_test_process_kind) == T_TEST_PROCESS_KIND # noqa: E721
assert type(g_test_process_kind) is T_TEST_PROCESS_KIND

if g_test_process_kind == T_TEST_PROCESS_KIND.Master:
return

assert g_test_process_kind == T_TEST_PROCESS_KIND.Worker

assert g_test_process_mode is not None
assert type(g_test_process_mode) == T_TEST_PROCESS_MODE # noqa: E721
assert type(g_test_process_mode) is T_TEST_PROCESS_MODE

if g_test_process_mode == T_TEST_PROCESS_MODE.Collect:
return
Expand Down Expand Up @@ -1050,7 +1050,7 @@ def LOCAL__print_test_list2(
logging.info(" UNEXPECTED : {0}".format(TEST_PROCESS_STATS.cUnexpectedTests))
logging.info("")

assert type(TEST_PROCESS_STATS.cTotalDuration) == datetime.timedelta # noqa: E721
assert type(TEST_PROCESS_STATS.cTotalDuration) is datetime.timedelta

LOCAL__print_line1_with_header("TIME")
logging.info("")
Expand Down Expand Up @@ -1136,8 +1136,8 @@ def pytest_configure(config: pytest.Config) -> None:
g_test_process_mode = helper__detect_test_process_mode(config)
g_test_process_kind = helper__detect_test_process_kind(config)

assert type(g_test_process_kind) == T_TEST_PROCESS_KIND # noqa: E721
assert type(g_test_process_mode) == T_TEST_PROCESS_MODE # noqa: E721
assert type(g_test_process_kind) is T_TEST_PROCESS_KIND
assert type(g_test_process_mode) is T_TEST_PROCESS_MODE

if g_test_process_kind == T_TEST_PROCESS_KIND.Master:
pass
Expand Down
8 changes: 4 additions & 4 deletions tests/helpers/pg_node_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __str__(self) -> str:

def __repr__(self) -> str:
# It must be overrided!
assert type(self) == __class__ # noqa: E721
assert type(self) is __class__
r = "{}({}, {})".format(
__class__.__name__,
repr(self._data_dir),
Expand Down Expand Up @@ -100,7 +100,7 @@ def message(self) -> str:

for f, lines in self._files or []:
assert type(f) is str
assert type(lines) in [str, bytes] # noqa: E721
assert type(lines) in [str, bytes]
msg_parts.append(u'{}\n----\n{}\n'.format(f, lines))

return "\n".join(msg_parts)
Expand Down Expand Up @@ -157,7 +157,7 @@ def wait_for_running_state(
timeout: T_WAIT_TIME,
):
assert type(node) is PostgresNode
assert type(node_log_reader) == PostgresNodeLogReader # noqa: E721
assert type(node_log_reader) is PostgresNodeLogReader
assert type(timeout) in [int, float]
assert node_log_reader._node is node
assert timeout > 0
Expand All @@ -176,7 +176,7 @@ def wait_for_running_state(
assert type(blocks) is list

for block in blocks:
assert type(block) == PostgresNodeLogReader.LogDataBlock # noqa: E721
assert type(block) is PostgresNodeLogReader.LogDataBlock

if 'Is another postmaster already running on port' in block.data:
raise __class__.PortConflictNodeException(node.data_dir, node.port)
Expand Down
30 changes: 15 additions & 15 deletions tests/test_os_ops_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_create_clone(self, os_ops: OsOperations):
clone = os_ops.create_clone()
assert clone is not None
assert clone is not os_ops
assert type(clone) == type(os_ops) # noqa: E721
assert type(clone) is type(os_ops)

def test_exec_command_success(self, os_ops: OsOperations):
"""
Expand Down Expand Up @@ -759,11 +759,11 @@ def __init__(self, sign, source, cp_rw, cp_truncate, cp_binary, cp_data, result)
)
def write_data001(self, request):
assert isinstance(request, pytest.FixtureRequest)
assert type(request.param) == __class__.tagWriteData001 # noqa: E721
assert type(request.param) is __class__.tagWriteData001
return request.param

def test_write(self, write_data001: tagWriteData001, os_ops: OsOperations):
assert type(write_data001) == __class__.tagWriteData001 # noqa: E721
assert type(write_data001) is __class__.tagWriteData001
assert isinstance(os_ops, OsOperations)

mode = "w+b" if write_data001.call_param__binary else "w+"
Expand Down Expand Up @@ -847,7 +847,7 @@ def test_is_port_free__false(self, os_ops: OsOperations):

def LOCAL_server(s: socket.socket):
assert s is not None
assert type(s) == socket.socket # noqa: E721
assert type(s) is socket.socket

try:
while True:
Expand All @@ -873,7 +873,7 @@ def LOCAL_server(s: socket.socket):

s.listen(10)

assert type(th) == threading.Thread # noqa: E721
assert type(th) is threading.Thread
th.start()

try:
Expand Down Expand Up @@ -964,7 +964,7 @@ def data001(self, request: pytest.FixtureRequest) -> tagData_OS_OPS__NUMS:
return request.param

def test_mkdir__mt(self, data001: tagData_OS_OPS__NUMS):
assert type(data001) == __class__.tagData_OS_OPS__NUMS # noqa: E721
assert type(data001) is __class__.tagData_OS_OPS__NUMS

N_WORKERS = 4
N_NUMBERS = data001.nums
Expand Down Expand Up @@ -1003,7 +1003,7 @@ def LOCAL_WORKER(os_ops: OsOperations,

def LOG_INFO(template: str, *args) -> None:
assert type(template) is str
assert type(args) == tuple # noqa: E721
assert type(args) is tuple

msg = template.format(*args)
assert type(msg) is str
Expand Down Expand Up @@ -1226,14 +1226,14 @@ class tadWorkerData:
)
def kill_signal_id(self, request: pytest.FixtureRequest) -> T_KILL_SIGNAL_DESCR:
assert isinstance(request, pytest.FixtureRequest)
assert type(request.param) == tuple # noqa: E721
assert type(request.param) is tuple
return request.param

def test_kill_signal(
self,
kill_signal_id: T_KILL_SIGNAL_DESCR,
):
assert type(kill_signal_id) == tuple # noqa: E721
assert type(kill_signal_id) is tuple
assert "{}".format(kill_signal_id[1]) == kill_signal_id[2]
assert "{}".format(int(kill_signal_id[1])) == kill_signal_id[2]

Expand All @@ -1246,7 +1246,7 @@ def test_kill(
Test listdir for listing directory contents.
"""
assert isinstance(os_ops, OsOperations)
assert type(kill_signal_id) == tuple # noqa: E721
assert type(kill_signal_id) is tuple

cmd = [
sys.executable,
Expand All @@ -1261,7 +1261,7 @@ def test_kill(
)

assert proc is not None
assert type(proc) == subprocess.Popen # noqa: E721
assert type(proc) is subprocess.Popen
proc_pid = proc.pid
assert type(proc_pid) is int
logging.info("Test process pid is {}".format(proc_pid))
Expand Down Expand Up @@ -1315,7 +1315,7 @@ def test_kill__unk_pid(
Test listdir for listing directory contents.
"""
assert isinstance(os_ops, OsOperations)
assert type(kill_signal_id) == tuple # noqa: E721
assert type(kill_signal_id) is tuple

cmd = [
sys.executable,
Expand All @@ -1332,7 +1332,7 @@ def test_kill__unk_pid(
)

assert proc is not None
assert type(proc) == subprocess.Popen # noqa: E721
assert type(proc) is subprocess.Popen
proc_pid = proc.pid
assert type(proc_pid) is int
logging.info("Test process pid is {}".format(proc_pid))
Expand Down Expand Up @@ -1387,10 +1387,10 @@ def test_kill__unk_pid(
logging.info("Our exception has type [{}]".format(type(x.value).__name__))

if type(os_ops).__name__ == "LocalOsOperations":
assert type(x.value) == ProcessLookupError # noqa: E721
assert type(x.value) is ProcessLookupError
assert "No such process" in str(x.value)
elif type(os_ops).__name__ == "RemoteOsOperations":
assert type(x.value) == ExecUtilException # noqa: E721
assert type(x.value) is ExecUtilException
assert "No such process" in str(x.value)
else:
RuntimeError("Unknown os_ops type: {}".format(type(os_ops).__name__))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_os_ops_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_rmdirs__try_to_delete_file(self, os_ops: OsOperations):
os_ops.rmdirs(path, ignore_errors=False)

assert os.path.exists(path)
assert type(x.value) == ExecUtilException # noqa: E721
assert type(x.value.description) == str # noqa: E721
assert type(x.value) is ExecUtilException
assert type(x.value.description) is str
assert x.value.description == "Utility exited with non-zero code (20). Error: `cannot remove '" + path + "': it is not a directory`"
assert x.value.message.startswith(x.value.description)
assert type(x.value.error) is str
Expand Down
Loading