Skip to content
Closed
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
8 changes: 4 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[MASTER]
persistent=no
ignore-paths=qubes/tests
ignore-paths=^qubes/tests/(?!integ/(dispvm|network).*$)(?!(app|api|ext|vm/(adminvm|appvm|dispvm|mix/(dvmtemplate|net))).py$).*
init-hook="import astroid.bases; astroid.bases.POSSIBLE_PROPERTIES.add('stateless_property')"

[MESSAGES CONTROL]
Expand Down Expand Up @@ -61,10 +61,10 @@ class-rgx=([A-Z_][a-zA-Z0-9]+|TC_\d\d_[a-zA-Z0-9_]+)$
function-rgx=(test_[0-9]{3}_[a-z0-9_]{2,50}|[a-z_][a-z0-9_]{2,50})$

# Regular expression which should only match correct method names
method-rgx=(test_[0-9]{3}_[a-z0-9_]{2,50}|[a-z_][a-z0-9_]{2,50})$
method-rgx=(setUp|setUpClass|tearDown|tearDownClass|test_[0-9]{3}_[a-z0-9_]{2,50}|[a-z_][a-z0-9_]{2,50})$

# Regular expression which should only match correct instance attribute names
attr-rgx=[a-z_][a-z0-9_]{2,40}$
attr-rgx=(maxDiff|[a-z_][a-z0-9_]{2,40})$

# Regular expression which should only match correct argument names
argument-rgx=[a-z_][a-z0-9_]{2,40}$
Expand Down Expand Up @@ -198,6 +198,6 @@ max-positional-arguments=7

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception,EnvironmentError
overgeneral-exceptions=builtins.Exception,builtins.EnvironmentError

# vim: ft=conf
2 changes: 1 addition & 1 deletion qubes/ext/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def compare_device_cache(vm, devices_cache, current_devices):
async def confirm_device_attachment(device, frontends) -> str:
try:
return await _do_confirm_device_attachment(device, frontends)
except Exception as exc:
except Exception as exc: # pylint: disable=broad-exception-caught
print(str(exc.__class__.__name__) + ":", str(exc), file=sys.stderr)
return ""

Expand Down
2 changes: 1 addition & 1 deletion qubes/qmemman/systemstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def mem_set(self, domid, val) -> None:
int(domid), int(val / 1024) + 1024
) # LIBXL_MAXMEM_CONSTANT=1024
self.xc.domain_set_target_mem(int(domid), int(val / 1024))
except Exception:
except Exception: # pylint: disable=broad-exception-caught
pass
# VM sees about 16MB memory less, so adjust for it here - qmemman
# handle Xen view of memory
Expand Down
2 changes: 1 addition & 1 deletion qubes/rngdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_child_elements(self):
number = "\\+"
else:
print(parent.tag)
raise Exception(
raise ValueError(
f"Cannot choose number format for tag {parent.tag}"
)

Expand Down
9 changes: 6 additions & 3 deletions qubes/tests/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
import qubes.tests


class TestMgmt(object):
class TestMgmt:
def __init__(self, app, src, method, dest, arg, send_event=None):
self.app = app
self.src = src
self.method = method
self.dest = dest
self.arg = arg
self.send_event = send_event
self.task = None
try:
self.function = {
"mgmt.success": self.success,
Expand Down Expand Up @@ -67,12 +68,14 @@ async def qubesexception(self, untrusted_payload):
raise qubes.exc.QubesException("qubes-exception")

async def exception(self, untrusted_payload):
# pylint: disable=broad-exception-raised
raise Exception("exception")

async def event(self, untrusted_payload):
future = asyncio.get_event_loop().create_future()

class Subject:
# pylint: disable=too-few-public-methods
name = "subject"

def __str__(self):
Expand All @@ -93,7 +96,7 @@ def __str__(self):

class TC_00_QubesDaemonProtocol(qubes.tests.QubesTestCase):
def setUp(self):
super(TC_00_QubesDaemonProtocol, self).setUp()
super().setUp()
self.app = unittest.mock.Mock()
self.app.log = self.log
self.sock_client, self.sock_server = socket.socketpair()
Expand All @@ -116,7 +119,7 @@ def tearDown(self):
except AttributeError: # old python in travis
pass
self.transport.close()
super(TC_00_QubesDaemonProtocol, self).tearDown()
super().tearDown()

def test_000_message_ok(self):
self.writer.write(b"mgmt.success+arg src name dest\0payload")
Expand Down
4 changes: 2 additions & 2 deletions qubes/tests/api_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import uuid


def mock_coro(f):
def mock_coro(coro):
async def coro_f(*args, **kwargs):
return f(*args, **kwargs)
return coro(*args, **kwargs)

return coro_f

Expand Down
10 changes: 5 additions & 5 deletions qubes/tests/api_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
maxDiff = None

def setUp(self):
super(TC_00_API_Misc, self).setUp()
super().setUp()
self.tpl = mock.NonCallableMagicMock(name="template")
del self.tpl.template
self.async_src = mock.AsyncMock()
Expand Down Expand Up @@ -393,9 +393,9 @@ def test_027_notify_updates_template_based_template_running(self):
self.assertEqual(self.app.mock_calls, [])

def test_028_notify_updates_template_based_dispvm(self):
self.dvm = self.src
self.dvm.updateable = False
self.srv = mock.NonCallableMagicMock(template=self.dvm)
dvm = self.src
dvm.updateable = False
_srv = mock.NonCallableMagicMock(template=dvm)
self.src.updateable = False
self.src.features.get.return_value = False
self.src.template.is_running.return_value = False
Expand Down Expand Up @@ -424,7 +424,7 @@ def test_028_notify_updates_template_based_dispvm(self):
+ "\nExpected:\n"
+ str(expected).replace(",", ",\n"),
)
self.assertEqual(self.dvm.mock_calls, [])
self.assertEqual(dvm.mock_calls, [])
self.assertIsInstance(self.src.updates_available, mock.Mock)
self.assertEqual(self.app.mock_calls, [mock.call.save()])

Expand Down
Loading