Skip to content

Commit

Permalink
Fixes for flake8 reported whitespace problems. (#39)
Browse files Browse the repository at this point in the history
* Fixes for flake8 reported whitespace problems.

Most of the whitespace problems are fixed by this change, just removing
or adding lines or spaces around statements.

* Update the flake8 and runtest runners to include shebang.

No shebang line meant that these might not run properly.

* Comma whitespace fix.

A small fix that was missed in earlier changes.
  • Loading branch information
gerph authored Nov 15, 2023
1 parent da58365 commit f115370
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 50 deletions.
8 changes: 4 additions & 4 deletions Hyper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ def file_load(filename):
size = header[1]
buffer = (ctypes.c_byte * size)()

ws_size = swi.swi("Squash_Decompress", "II;I", 8, sq_size-20)
ws_size = swi.swi("Squash_Decompress", "II;I", 8, sq_size - 20)
workspace = (ctypes.c_byte * ws_size)()

swi.swi("Squash_Decompress", "iIIIII", 4,
ctypes.addressof(workspace),
ctypes.addressof(squashed)+20,
sq_size-20,
ctypes.addressof(squashed) + 20,
sq_size - 20,
ctypes.addressof(buffer), size)

return buffer, size


if __name__ == "__main__":
print(file_load("underlay"))
3 changes: 2 additions & 1 deletion flake8.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
python3 -m flake8 . --count --ignore=E221,E501 --show-source --statistics
#!/bin/bash
python3 -m flake8 . --count --ignore=E221,E501,E227 --show-source --statistics
4 changes: 2 additions & 2 deletions riscos_toolbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def run(application):
global _quit

while not _quit:
reason,sender = swi.swi(
'Wimp_Poll','II;I.I',
reason, sender = swi.swi(
'Wimp_Poll', 'II;I.I',
application.poll_flags,
ctypes.addressof(poll_buffer))

Expand Down
2 changes: 1 addition & 1 deletion riscos_toolbox/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IDBlock(ctypes.Structure):
]

def __repr__(self):
return "Acestor: {} Parent: {} Self: {}".format(self.ancestor, self.parent, self.self)
return "Ancestor: {} Parent: {} Self: {}".format(self.ancestor, self.parent, self.self)


class Point(ctypes.Structure):
Expand Down
1 change: 1 addition & 0 deletions runtest.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#!/bin/bash
python -m unittest discover -s test
8 changes: 7 additions & 1 deletion test/components/test_saveas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

import swi


TEST_OBJECT_ID = 0x1001
TEST_WINDOW_ID = 0x2001
TEST_TITLE = "Test Title"
TEST_NAME = "Test"


class SwiMock:
def __init__(self):
self._expect = []
Expand All @@ -37,7 +39,7 @@ def argmatch(a, b):
return True

if not argmatch(exp, args):
raise RuntimeError("SWI call mismatch: got {} exp {}".format(args, exp))
raise RuntimeError("SWI call mismatch: got {} exp {}".format(args, exp))

self._pos += 1
return ret
Expand All @@ -50,6 +52,7 @@ def expect(self, exp, ret=None):
def completed(self):
return self._pos == len(self._expect)


class MockBlockString:
def __init__(self, string):
self.string = string
Expand All @@ -60,13 +63,16 @@ def __call__(self, *args):
def nullstring(self):
return self.string


def expect_miscop(obj, op, ret):
return (('Toolbox_ObjectMiscOp', 'III;I', 0, obj, op), ret)


def expect_miscop_string(swimock, obj, op, str):
swimock.expect(('Toolbox_ObjectMiscOp', 'III00;....I', 0, obj, op), len(str))
swimock.expect(('Toolbox_ObjectMiscOp', 'IIIbI', 0, obj, op, None, len(str)), None)


class SaveAs(unittest.TestCase):

def test_window_id(self):
Expand Down
7 changes: 4 additions & 3 deletions test/events/test_redraw_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import unittest
import struct


class RedrawWindow(unittest.TestCase):

def test_from_init(self):
rw = redraw_window.RedrawWindow()
assert(rw.event_id == 1)
assert (rw.event_id == 1)

def test_from_block(self):
rw = redraw_window.RedrawWindow.from_poll_block(
struct.pack("i", 42)
)
assert(rw.event_id == 1)
assert(rw.window_handle == 42)
assert (rw.event_id == 1)
assert (rw.window_handle == 42)
5 changes: 4 additions & 1 deletion test/fakeswi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
def swi(*args):
pass


class block:
def __init__(self, *args):
pass


import unittest

import fakeswi
import sys

sys.modules['swi'] = fakeswi

"""
import riscos_toolbox as toolbox
import riscos_toolbox.objects.saveas
Expand Down Expand Up @@ -92,4 +96,3 @@ def test_get_title(self):
self.assertEqual(saveas.title, "Test Title")
self.assertTrue(swimock.completed)
"""

5 changes: 5 additions & 0 deletions test/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

calls = []


class TestClass01(toolbox.Object):
def __init__(self, id):
super().__init__(id, "test")
Expand All @@ -22,6 +23,7 @@ def __init__(self, id):
def event_c101(self, event, id_block, poll_block):
calls.append((self.__class__.__name__, self.id, event, id_block, poll_block))


class TestClass02(toolbox.Object):
def __init__(self, id):
super().__init__(id, "test")
Expand All @@ -33,6 +35,7 @@ def __init__(self, id):
def event_c102(self, event, id_block, poll_block):
calls.append((self.__class__.__name__, self.id, event, id_block, poll_block))


class TestClass03(toolbox.Object):
def __init__(self, id):
super().__init__(id, "test")
Expand All @@ -41,10 +44,12 @@ def __init__(self, id):
def event_c103(self, event, id_block, poll_block):
calls.append((self.__class__.__name__, self.id, event, id_block, poll_block))


@toolbox_handler(0xff01)
def test_func(event, id_block, *args):
calls.append((test_func.__name__, None, event, id_block, args))


class ObjectDispatchTest(unittest.TestCase):
def setUp(self):
calls.clear()
Expand Down
2 changes: 1 addition & 1 deletion test/test_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import riscos_toolbox as toolbox


class ToolboxTest(unittest.TestCase):
def test_one(self):
self.assertEqual(0, 0)

Loading

0 comments on commit f115370

Please sign in to comment.