remove @staticmethod decorators
There might have been a time when calling a static method was faster than a regular method, but that is no longer the case. According to micro-benchmarks, it is 70% slower in CPython 3.13 and it also makes executing the code of a class definition slower.
This commit is contained in:
@@ -223,8 +223,7 @@ class TestConfigFiles(unittest.TestCase):
|
||||
self.assertIsInstance(cfg, dict)
|
||||
self.assertTrue(cfg)
|
||||
|
||||
@staticmethod
|
||||
def _load(name):
|
||||
def _load(self, name):
|
||||
path = os.path.join(ROOTDIR, "docs", name)
|
||||
try:
|
||||
with open(path) as fp:
|
||||
|
||||
@@ -296,8 +296,7 @@ class TestExtractorWait(unittest.TestCase):
|
||||
u = self._isotime_to_seconds(until.time().isoformat()[:8])
|
||||
self.assertLessEqual(o-u, 1.0)
|
||||
|
||||
@staticmethod
|
||||
def _isotime_to_seconds(isotime):
|
||||
def _isotime_to_seconds(self, isotime):
|
||||
parts = isotime.split(":")
|
||||
return int(parts[0]) * 3600 + int(parts[1]) * 60 + int(parts[2])
|
||||
|
||||
|
||||
@@ -713,8 +713,7 @@ class MetadataTest(BasePostprocessorTest):
|
||||
}
|
||||
""")
|
||||
|
||||
@staticmethod
|
||||
def _output(mock):
|
||||
def _output(self, mock):
|
||||
return "".join(
|
||||
call[1][0]
|
||||
for call in mock.mock_calls
|
||||
|
||||
@@ -28,11 +28,18 @@ from gallery_dl import util, text, exception # noqa E402
|
||||
|
||||
class TestRange(unittest.TestCase):
|
||||
|
||||
def test_parse_empty(self, f=util.RangePredicate._parse):
|
||||
def setUp(self):
|
||||
self.predicate = util.RangePredicate("")
|
||||
|
||||
def test_parse_empty(self):
|
||||
f = self.predicate._parse
|
||||
|
||||
self.assertEqual(f(""), [])
|
||||
self.assertEqual(f([]), [])
|
||||
|
||||
def test_parse_digit(self, f=util.RangePredicate._parse):
|
||||
def test_parse_digit(self):
|
||||
f = self.predicate._parse
|
||||
|
||||
self.assertEqual(f("2"), [range(2, 3)])
|
||||
|
||||
self.assertEqual(
|
||||
@@ -42,7 +49,9 @@ class TestRange(unittest.TestCase):
|
||||
range(4, 5)],
|
||||
)
|
||||
|
||||
def test_parse_range(self, f=util.RangePredicate._parse):
|
||||
def test_parse_range(self):
|
||||
f = self.predicate._parse
|
||||
|
||||
self.assertEqual(f("1-2"), [range(1, 3)])
|
||||
self.assertEqual(f("2-"), [range(2, sys.maxsize)])
|
||||
self.assertEqual(f("-3"), [range(1, 4)])
|
||||
@@ -62,7 +71,9 @@ class TestRange(unittest.TestCase):
|
||||
range(2, 7)],
|
||||
)
|
||||
|
||||
def test_parse_slice(self, f=util.RangePredicate._parse):
|
||||
def test_parse_slice(self):
|
||||
f = self.predicate._parse
|
||||
|
||||
self.assertEqual(f("2:4") , [range(2, 4)])
|
||||
self.assertEqual(f("3::") , [range(3, sys.maxsize)])
|
||||
self.assertEqual(f(":4:") , [range(1, 4)])
|
||||
|
||||
Reference in New Issue
Block a user