@staticmethod
PYL-R0201 9
10
11class TestCreateRegex(unittest.TestCase):
12 def test_clone_basic(self):13 orig = sre_parse.parse(r"a{2}")
14 new = clone_subpattern(orig)
15 sre_compile.compile(new)
15 sre_compile.compile(new)
16 assert _val_eq(orig, new)
17
18 def test_create_basic(self):19 orig = sre_parse.parse(r"a{2}")
20 new = create_subpattern(orig.data)
21 sre_compile.compile(new)
100
101 assert rv[1].data == [(sre_parse.LITERAL, ord("b"))]
102
103 def test_split_class(self):104 rv = split_regex(r"a[/]b", "/", remainer=True)
105 assert isinstance(rv, tuple), rv
106 assert isinstance(rv[0], sre_parse.SubPattern), rv
108
109 assert rv[1].data == [(sre_parse.LITERAL, ord("b"))]
110
111 def test_split_class2(self):112 rv = split_regex(r"a[(/]b", "/", remainer=True)
113 assert isinstance(rv, tuple), rv
114 assert isinstance(rv[0], sre_parse.SubPattern), rv
92
93 assert rv[1].data == [(sre_parse.LITERAL, ord("b"))]
94
95 def test_split_star(self): 96 rv = split_regex(r"a/*b", "/", remainer=True)
97 assert isinstance(rv, tuple), rv
98 assert isinstance(rv[0], sre_parse.SubPattern), rv
The method doesn't use its bound instance. Decorate this method with @staticmethod
decorator, so that Python does not have to instantiate a bound method for every instance of this class thereby saving memory and computation. Read more about staticmethods here.