How to use check_value method in Slash

Best Python code snippet using slash

RUNLIST.py

Source:RUNLIST.py Github

copy

Full Screen

...3from pyglet.text import runlist4import unittest5__noninteractive = True6class TestStyleRuns(unittest.TestCase):7 def check_value(self, runs, value):8 for i, style in enumerate(value):9 self.assertTrue(runs[i] == style, repr(runs.runs))10 self.check_optimal(runs)11 self.check_continuous(runs)12 self.check_iter(runs, value)13 self.check_iter_range(runs, value)14 def check_optimal(self, runs):15 last_style = None16 for _, _, style in runs:17 self.assertTrue(style != last_style)18 last_style = style19 def check_continuous(self, runs):20 next_start = 021 for start, end, _ in runs:22 self.assertTrue(start == next_start)23 next_start = end24 def check_iter(self, runs, value):25 for start, end, style in runs:26 for v in value[start:end]:27 self.assertTrue(v == style)28 def check_iter_range(self, runs, value):29 for interval in range(1, len(value)):30 it = runs.get_run_iterator()31 for start in range(0, len(value), interval):32 end = min(start + interval, len(value))33 for s, e, style in it.ranges(start, end):34 for v in value[s:e]:35 self.assertTrue(v == style, (start, end, s, e, style))36 def check_empty(self, runs, value):37 start, end, style = iter(runs).next()38 self.assertTrue(start == 0)39 self.assertTrue(end == 0)40 self.assertTrue(style == value)41 def test_zero(self):42 runs = runlist.RunList(0, 'x')43 it = iter(runs)44 45 start, end, s = it.next()46 self.assertTrue(start == 0)47 self.assertTrue(end == 0)48 self.assertTrue(s == 'x')49 self.assertRaises(StopIteration, it.next)50 self.check_optimal(runs)51 def test_initial(self):52 runs = runlist.RunList(10, 'x')53 it = iter(runs)54 start, end, s = it.next()55 self.assertTrue(start == 0)56 self.assertTrue(end == 10)57 self.assertTrue(s == 'x')58 self.assertRaises(StopIteration, it.next)59 self.check_value(runs, 'x' * 10)60 def test_set1(self):61 runs = runlist.RunList(10, 'a')62 runs.set_run(2, 8, 'b')63 self.check_value(runs, 'aabbbbbbaa')64 def test_set1_start(self):65 runs = runlist.RunList(10, 'a')66 runs.set_run(0, 5, 'b')67 self.check_value(runs, 'bbbbbaaaaa')68 def test_set1_end(self):69 runs = runlist.RunList(10, 'a')70 runs.set_run(5, 10, 'b')71 self.check_value(runs, 'aaaaabbbbb')72 def test_set1_all(self):73 runs = runlist.RunList(10, 'a')74 runs.set_run(0, 10, 'b')75 self.check_value(runs, 'bbbbbbbbbb')76 def test_set1_1(self):77 runs = runlist.RunList(10, 'a')78 runs.set_run(1, 2, 'b')79 self.check_value(runs, 'abaaaaaaaa')80 81 def test_set_overlapped(self):82 runs = runlist.RunList(10, 'a')83 runs.set_run(0, 5, 'b')84 self.check_value(runs, 'bbbbbaaaaa')85 runs.set_run(5, 10, 'c')86 self.check_value(runs, 'bbbbbccccc')87 runs.set_run(3, 7, 'd')88 self.check_value(runs, 'bbbddddccc')89 runs.set_run(4, 6, 'e')90 self.check_value(runs, 'bbbdeedccc')91 runs.set_run(5, 9, 'f')92 self.check_value(runs, 'bbbdeffffc')93 runs.set_run(2, 3, 'g')94 self.check_value(runs, 'bbgdeffffc')95 runs.set_run(1, 3, 'h')96 self.check_value(runs, 'bhhdeffffc')97 runs.set_run(1, 9, 'i')98 self.check_value(runs, 'biiiiiiiic')99 runs.set_run(0, 10, 'j')100 self.check_value(runs, 'jjjjjjjjjj')101 def test_insert_empty(self):102 runs = runlist.RunList(0, 'a')103 runs.insert(0, 10)104 self.check_value(runs, 'aaaaaaaaaa')105 def test_insert_beginning(self):106 runs = runlist.RunList(5, 'a')107 runs.set_run(1, 4, 'b')108 self.check_value(runs, 'abbba')109 runs.insert(0, 3)110 self.check_value(runs, 'aaaabbba')111 def test_insert_beginning_1(self):112 runs = runlist.RunList(5, 'a')113 self.check_value(runs, 'aaaaa')114 runs.insert(0, 1)115 runs.set_run(0, 1, 'a')116 self.check_value(runs, 'aaaaaa')117 runs.insert(0, 1)118 runs.set_run(0, 1, 'a')119 self.check_value(runs, 'aaaaaaa')120 runs.insert(0, 1)121 runs.set_run(0, 1, 'a')122 self.check_value(runs, 'aaaaaaaa')123 def test_insert_beginning_2(self):124 runs = runlist.RunList(5, 'a')125 self.check_value(runs, 'aaaaa')126 runs.insert(0, 1)127 runs.set_run(0, 1, 'b')128 self.check_value(runs, 'baaaaa')129 runs.insert(0, 1)130 runs.set_run(0, 1, 'c')131 self.check_value(runs, 'cbaaaaa')132 runs.insert(0, 1)133 runs.set_run(0, 1, 'c')134 self.check_value(runs, 'ccbaaaaa')135 def test_insert_1(self):136 runs = runlist.RunList(5, 'a')137 runs.set_run(1, 4, 'b')138 self.check_value(runs, 'abbba')139 runs.insert(1, 3)140 self.check_value(runs, 'aaaabbba')141 def test_insert_2(self):142 runs = runlist.RunList(5, 'a')143 runs.set_run(1, 2, 'b')144 self.check_value(runs, 'abaaa')145 runs.insert(2, 3)146 self.check_value(runs, 'abbbbaaa')147 def test_insert_end(self):148 runs = runlist.RunList(5, 'a')149 runs.set_run(4, 5, 'b')150 self.check_value(runs, 'aaaab')151 runs.insert(5, 3)152 self.check_value(runs, 'aaaabbbb')153 def test_insert_almost_end(self):154 runs = runlist.RunList(5, 'a')155 runs.set_run(0, 3, 'b')156 runs.set_run(4, 5, 'c')157 self.check_value(runs, 'bbbac')158 runs.insert(4, 3)159 self.check_value(runs, 'bbbaaaac') 160 def test_delete_1_beginning(self):161 runs = runlist.RunList(5, 'a')162 self.check_value(runs, 'aaaaa') 163 runs.delete(0, 3)164 self.check_value(runs, 'aa') 165 def test_delete_1_middle(self):166 runs = runlist.RunList(5, 'a')167 self.check_value(runs, 'aaaaa') 168 runs.delete(1, 4)169 self.check_value(runs, 'aa') 170 171 def test_delete_1_end(self):172 runs = runlist.RunList(5, 'a')173 self.check_value(runs, 'aaaaa') 174 runs.delete(2, 5)175 self.check_value(runs, 'aa') 176 def test_delete_1_all(self):177 runs = runlist.RunList(5, 'a')178 self.check_value(runs, 'aaaaa') 179 runs.delete(0, 5)180 self.check_value(runs, '') 181 self.check_empty(runs, 'a')182 def create_runs1(self):183 runs = runlist.RunList(10, 'a')184 runs.set_run(1, 10, 'b')185 runs.set_run(2, 10, 'c')186 runs.set_run(3, 10, 'd')187 runs.set_run(4, 10, 'e')188 runs.set_run(5, 10, 'f')189 runs.set_run(6, 10, 'g')190 runs.set_run(7, 10, 'h')191 runs.set_run(8, 10, 'i')192 runs.set_run(9, 10, 'j')193 self.check_value(runs, 'abcdefghij')194 return runs195 def create_runs2(self):196 runs = runlist.RunList(10, 'a')197 runs.set_run(4, 7, 'b')198 runs.set_run(7, 10, 'c')199 self.check_value(runs, 'aaaabbbccc')200 return runs201 def test_delete2(self):202 runs = self.create_runs1()203 runs.delete(0, 5)204 self.check_value(runs, 'fghij')205 def test_delete3(self):206 runs = self.create_runs1()207 runs.delete(2, 8)208 self.check_value(runs, 'abij')209 def test_delete4(self):210 runs = self.create_runs2()211 runs.delete(0, 5)212 self.check_value(runs, 'bbccc')213 214 def test_delete5(self):215 runs = self.create_runs2()216 runs.delete(5, 10)217 self.check_value(runs, 'aaaab') 218 def test_delete6(self):219 runs = self.create_runs2()220 runs.delete(0, 8)221 self.check_value(runs, 'cc') 222 def test_delete7(self):223 runs = self.create_runs2()224 runs.delete(2, 10)225 self.check_value(runs, 'aa') 226 def test_delete8(self):227 runs = self.create_runs2()228 runs.delete(3, 8)229 self.check_value(runs, 'aaacc')230 def test_delete9(self):231 runs = self.create_runs2()232 runs.delete(7, 8)233 self.check_value(runs, 'aaaabbbcc')234 def test_delete10(self):235 runs = self.create_runs2()236 runs.delete(8, 9) 237 self.check_value(runs, 'aaaabbbcc')238 def test_delete11(self):239 runs = self.create_runs2()240 runs.delete(9, 10)241 self.check_value(runs, 'aaaabbbcc')242 def test_delete12(self):243 runs = self.create_runs2()244 runs.delete(4, 5)245 self.check_value(runs, 'aaaabbccc')246 def test_delete13(self):247 runs = self.create_runs2()248 runs.delete(5, 6)249 self.check_value(runs, 'aaaabbccc')250 def test_delete14(self):251 runs = self.create_runs2()252 runs.delete(6, 7)253 self.check_value(runs, 'aaaabbccc')254if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful