How to use absolute_path method in autotest

Best Python code snippet using autotest_python

OCR_test.py

Source:OCR_test.py Github

copy

Full Screen

1import cv22import pytesseract3import os4import numpy as np5import re6from pytessy.pytessy import PyTessy7import logging8import string, re9import sys10import unittest11from tesseract_ocr import *12class TestOCRCheck(unittest.TestCase):13 def setUp(self):14 self.ocr = OCR_PyTes()15 16 def tearDown(self) -> None:17 self.ocr.depose()18 del self.ocr19 def test_card1(self):20 absolute_path = os.path.join(os.getcwd(), 'card (1).png')21 images = cv2.imread(absolute_path)22 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)23 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)24 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)25 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)26 27 def test_card2(self):28 absolute_path = os.path.join(os.getcwd(), 'card (2).png')29 images = cv2.imread(absolute_path)30 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)31 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)32 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)33 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)34 35 def test_card3(self):36 absolute_path = os.path.join(os.getcwd(), 'card (3).png')37 images = cv2.imread(absolute_path)38 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)39 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)40 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)41 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)42 43 def test_card4(self):44 absolute_path = os.path.join(os.getcwd(), 'card (4).png')45 images = cv2.imread(absolute_path)46 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)47 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)48 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)49 50 def test_card5(self):51 absolute_path = os.path.join(os.getcwd(), 'card (5).png')52 images = cv2.imread(absolute_path)53 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)54 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)55 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)56 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)57 58 def test_card6(self):59 absolute_path = os.path.join(os.getcwd(), 'card (6).png')60 images = cv2.imread(absolute_path)61 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)62 self.assertEqual(self.ocr.get_print_num(images,1),10)63 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)64 65 def test_card7(self):66 absolute_path = os.path.join(os.getcwd(), 'card (7).png')67 images = cv2.imread(absolute_path)68 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)69 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)70 self.assertEqual(self.ocr.get_print_num(images,2),10)71 72 def test_card8(self):73 absolute_path = os.path.join(os.getcwd(), 'card (8).png')74 images = cv2.imread(absolute_path)75 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)76 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)77 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)78 def test_card9(self):79 absolute_path = os.path.join(os.getcwd(), 'card (9).png')80 images = cv2.imread(absolute_path)81 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)82 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)83 self.assertTrue(self.ocr.get_print_num(images,2)==1000)84 self.assertTrue(self.ocr.get_print_num(images,3)>=10000) 85 def test_card10(self):86 absolute_path = os.path.join(os.getcwd(), 'card (10).png')87 images = cv2.imread(absolute_path)88 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)89 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)90 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)91 def test_card11(self):92 absolute_path = os.path.join(os.getcwd(), 'card (11).png')93 images = cv2.imread(absolute_path)94 self.assertTrue(self.ocr.get_print_num(images,0)>=10000)95 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)96 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)97 98 def test_card12(self):99 absolute_path = os.path.join(os.getcwd(), 'card (12).png')100 images = cv2.imread(absolute_path)101 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)102 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)103 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)104 105 def test_card13(self):106 absolute_path = os.path.join(os.getcwd(), 'card (13).png')107 images = cv2.imread(absolute_path)108 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)109 self.assertTrue(self.ocr.get_print_num(images,1)>=1000)110 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)111 112 def test_card14(self):113 absolute_path = os.path.join(os.getcwd(), 'card (14).png')114 images = cv2.imread(absolute_path)115 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)116 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)117 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)118 119 def test_card15(self):120 absolute_path = os.path.join(os.getcwd(), 'card (15).png')121 images = cv2.imread(absolute_path)122 self.assertTrue(self.ocr.get_print_num(images,0)>=10000)123 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)124 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)125 126 def test_card16(self):127 absolute_path = os.path.join(os.getcwd(), 'card (16).png')128 images = cv2.imread(absolute_path)129 self.assertTrue(self.ocr.get_print_num(images,0)>=1000)130 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)131 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)132 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)133 134 def test_card17(self):135 absolute_path = os.path.join(os.getcwd(), 'card (17).png')136 images = cv2.imread(absolute_path)137 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)138 self.assertTrue(self.ocr.get_print_num(images,1)>=1000)139 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)140 141 def test_card18(self):142 absolute_path = os.path.join(os.getcwd(), 'card (18).png')143 images = cv2.imread(absolute_path)144 self.assertTrue(self.ocr.get_print_num(images,0)>=10000)145 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)146 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)147 148 def test_card19(self):149 absolute_path = os.path.join(os.getcwd(), 'card (19).png')150 images = cv2.imread(absolute_path)151 self.assertTrue(self.ocr.get_print_num(images,0)>=10000)152 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)153 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)154 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)155 156 def test_card20(self):157 absolute_path = os.path.join(os.getcwd(), 'card (20).png')158 images = cv2.imread(absolute_path)159 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)160 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)161 self.assertTrue(self.ocr.get_print_num(images,2)>=1000)162 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)163 164 def test_card21(self):165 absolute_path = os.path.join(os.getcwd(), 'card (21).png')166 images = cv2.imread(absolute_path)167 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)168 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)169 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)170 171 def test_card22(self):172 absolute_path = os.path.join(os.getcwd(), 'card (22).png')173 images = cv2.imread(absolute_path)174 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)175 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)176 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)177 178 def test_card23(self):179 absolute_path = os.path.join(os.getcwd(), 'card (23).png')180 images = cv2.imread(absolute_path)181 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)182 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)183 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)184 self.assertTrue(self.ocr.get_print_num(images,3)>=10000)185 186 def test_card24(self):187 absolute_path = os.path.join(os.getcwd(), 'card (24).png')188 images = cv2.imread(absolute_path)189 self.assertTrue(self.ocr.get_print_num(images,0)>=1000)190 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)191 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)192 193 def test_card25(self):194 absolute_path = os.path.join(os.getcwd(), 'card (25).png')195 images = cv2.imread(absolute_path)196 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)197 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)198 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)199 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)200 201 def test_card26(self):202 absolute_path = os.path.join(os.getcwd(), 'card (26).png')203 images = cv2.imread(absolute_path)204 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)205 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)206 self.assertTrue(self.ocr.get_print_num(images,2)==100)207 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)208 209 def test_card27(self):210 absolute_path = os.path.join(os.getcwd(), 'card (27).png')211 images = cv2.imread(absolute_path)212 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)213 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)214 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)215 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)216 217 def test_card28(self):218 absolute_path = os.path.join(os.getcwd(), 'card (28).png')219 images = cv2.imread(absolute_path)220 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)221 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)222 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)223 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)224 225 def test_card29(self):226 absolute_path = os.path.join(os.getcwd(), 'card (29).png')227 images = cv2.imread(absolute_path)228 self.assertTrue(self.ocr.get_print_num(images,0)>=10000)229 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)230 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)231 232 def test_card30(self):233 absolute_path = os.path.join(os.getcwd(), 'card (30).png')234 images = cv2.imread(absolute_path)235 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)236 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)237 self.assertTrue(self.ocr.get_print_num(images,2)>=1000)238 239 def test_card31(self):240 absolute_path = os.path.join(os.getcwd(), 'card (31).png')241 images = cv2.imread(absolute_path)242 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)243 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)244 self.assertTrue(self.ocr.get_print_num(images,2)>=1000)245 246 def test_card32(self):247 absolute_path = os.path.join(os.getcwd(), 'card (32).png')248 images = cv2.imread(absolute_path)249 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)250 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)251 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)252 253 def test_card33(self):254 absolute_path = os.path.join(os.getcwd(), 'card (33).png')255 images = cv2.imread(absolute_path)256 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)257 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)258 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)259 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)260 261 def test_card34(self):262 absolute_path = os.path.join(os.getcwd(), 'card (34).png')263 images = cv2.imread(absolute_path)264 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)265 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)266 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)267 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)268 269 def test_card35(self):270 absolute_path = os.path.join(os.getcwd(), 'card (35).png')271 images = cv2.imread(absolute_path)272 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)273 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)274 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)275 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)276 277 def test_card36(self):278 absolute_path = os.path.join(os.getcwd(), 'card (36).png')279 images = cv2.imread(absolute_path)280 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)281 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)282 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)283 284 def test_card37(self):285 absolute_path = os.path.join(os.getcwd(), 'card (37).png')286 images = cv2.imread(absolute_path)287 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)288 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)289 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)290 291 def test_card38(self):292 absolute_path = os.path.join(os.getcwd(), 'card (38).png')293 images = cv2.imread(absolute_path)294 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)295 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)296 self.assertTrue(self.ocr.get_print_num(images,2)>=1000)297 298 def test_card39(self):299 absolute_path = os.path.join(os.getcwd(), 'card (39).png')300 images = cv2.imread(absolute_path)301 self.assertTrue(self.ocr.get_print_num(images,0)>=1000)302 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)303 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)304 305 def test_card40(self):306 absolute_path = os.path.join(os.getcwd(), 'card (40).png')307 images = cv2.imread(absolute_path)308 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)309 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)310 self.assertTrue(self.ocr.get_print_num(images,2)==10)311 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)312 313 def test_card41(self):314 absolute_path = os.path.join(os.getcwd(), 'card (41).png')315 images = cv2.imread(absolute_path)316 self.assertTrue(self.ocr.get_print_num(images,0)>=100)317 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)318 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)319 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)320 321 def test_card42(self):322 absolute_path = os.path.join(os.getcwd(), 'card (42).png')323 images = cv2.imread(absolute_path)324 self.assertTrue(self.ocr.get_print_num(images,0)>=10000)325 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)326 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)327 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)328 329 def test_card43(self):330 absolute_path = os.path.join(os.getcwd(), 'card (43).png')331 images = cv2.imread(absolute_path)332 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)333 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)334 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)335 def test_card44(self):336 absolute_path = os.path.join(os.getcwd(), 'card (44).png')337 images = cv2.imread(absolute_path)338 self.assertTrue(self.ocr.get_print_num(images,0)>=1000)339 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)340 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)341 self.assertTrue(self.ocr.get_print_num(images,3)>=100000) 342 343 def test_card45(self):344 absolute_path = os.path.join(os.getcwd(), 'card (45).png')345 images = cv2.imread(absolute_path)346 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)347 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)348 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)349 350 def test_card46(self):351 absolute_path = os.path.join(os.getcwd(), 'card (46).png')352 images = cv2.imread(absolute_path)353 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)354 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)355 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)356 357 def test_card47(self):358 absolute_path = os.path.join(os.getcwd(), 'card (47).png')359 images = cv2.imread(absolute_path)360 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)361 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)362 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)363 364 def test_card48(self):365 absolute_path = os.path.join(os.getcwd(), 'card (48).png')366 images = cv2.imread(absolute_path)367 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)368 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)369 self.assertTrue(self.ocr.get_print_num(images,2)==100)370 371 def test_card49(self):372 absolute_path = os.path.join(os.getcwd(), 'card (49).png')373 images = cv2.imread(absolute_path)374 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)375 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)376 self.assertTrue(self.ocr.get_print_num(images,2)>=1000)377 378 def test_card50(self):379 absolute_path = os.path.join(os.getcwd(), 'card (50).png')380 images = cv2.imread(absolute_path)381 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)382 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)383 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)384 self.assertTrue(self.ocr.get_print_num(images,3)>=10000)385 386 def test_card51(self):387 absolute_path = os.path.join(os.getcwd(), 'card (51).png')388 images = cv2.imread(absolute_path)389 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)390 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)391 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)392 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)393 394 def test_card52(self):395 absolute_path = os.path.join(os.getcwd(), 'card (52).png')396 images = cv2.imread(absolute_path)397 self.assertTrue(self.ocr.get_print_num(images,0)==100)398 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)399 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)400 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)401 402 def test_card53(self):403 absolute_path = os.path.join(os.getcwd(), 'card (53).png')404 images = cv2.imread(absolute_path)405 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)406 self.assertTrue(self.ocr.get_print_num(images,1)==100)407 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)408 self.assertTrue(self.ocr.get_print_num(images,3)>=100000) 409 410 def test_card54(self):411 absolute_path = os.path.join(os.getcwd(), 'card (54).png')412 images = cv2.imread(absolute_path)413 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)414 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)415 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)416 self.assertTrue(self.ocr.get_print_num(images,3)==100)417 418 def test_card55(self):419 absolute_path = os.path.join(os.getcwd(), 'card (55).png')420 images = cv2.imread(absolute_path)421 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)422 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)423 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)424 self.assertTrue(self.ocr.get_print_num(images,3)>=10000)425 426 def test_card56(self):427 absolute_path = os.path.join(os.getcwd(), 'card (56).png')428 images = cv2.imread(absolute_path)429 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)430 self.assertTrue(self.ocr.get_print_num(images,1)>=100)431 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)432 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)433 434 def test_card57(self):435 absolute_path = os.path.join(os.getcwd(), 'card (57).png')436 images = cv2.imread(absolute_path)437 self.assertTrue(self.ocr.get_print_num(images,0)==10)438 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)439 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)440 def test_card58(self):441 absolute_path = os.path.join(os.getcwd(), 'card (58).png')442 images = cv2.imread(absolute_path)443 self.assertTrue(self.ocr.get_print_num(images,0)>=10000)444 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)445 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)446 def test_card59(self):447 absolute_path = os.path.join(os.getcwd(), 'card (59).png')448 images = cv2.imread(absolute_path)449 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)450 self.assertTrue(self.ocr.get_print_num(images,1)==100)451 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)452 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)453 454 def test_card60(self):455 absolute_path = os.path.join(os.getcwd(), 'card (60).png')456 images = cv2.imread(absolute_path)457 self.assertTrue(self.ocr.get_print_num(images,0)>=100)458 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)459 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)460 def test_card61(self):461 absolute_path = os.path.join(os.getcwd(), 'card (61).png')462 images = cv2.imread(absolute_path)463 self.assertTrue(self.ocr.get_print_num(images,0)==10)464 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)465 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)466 def test_card62(self):467 absolute_path = os.path.join(os.getcwd(), 'card (62).png')468 images = cv2.imread(absolute_path)469 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)470 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)471 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)472 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)473 474 def test_card63(self):475 absolute_path = os.path.join(os.getcwd(), 'card (63).png')476 images = cv2.imread(absolute_path)477 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)478 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)479 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)480 def test_card64(self):481 absolute_path = os.path.join(os.getcwd(), 'card (64).png')482 images = cv2.imread(absolute_path)483 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)484 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)485 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)486 487 def test_card66(self):488 absolute_path = os.path.join(os.getcwd(), 'card (66).png')489 images = cv2.imread(absolute_path)490 self.assertTrue(self.ocr.get_print_num(images,0)>=1000)491 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)492 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)493 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)494 495 def test_card67(self):496 absolute_path = os.path.join(os.getcwd(), 'card (67).png')497 images = cv2.imread(absolute_path)498 self.assertTrue(self.ocr.get_print_num(images,0)>=1000)499 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)500 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)501 502 def test_card68(self):503 absolute_path = os.path.join(os.getcwd(), 'card (68).png')504 images = cv2.imread(absolute_path)505 self.assertTrue(self.ocr.get_print_num(images,0)>=1000)506 self.assertTrue(self.ocr.get_print_num(images,1)>=10000)507 self.assertTrue(self.ocr.get_print_num(images,2)>=10000)508 self.assertTrue(self.ocr.get_print_num(images,3)>=100000)509 510 def test_card69(self):511 absolute_path = os.path.join(os.getcwd(), 'card (69).png')512 images = cv2.imread(absolute_path)513 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)514 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)515 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)516 self.assertTrue(self.ocr.get_print_num(images,3)>=1000)517 518 def test_card82(self):519 absolute_path = os.path.join(os.getcwd(), 'card (82).png')520 images = cv2.imread(absolute_path)521 self.assertTrue(self.ocr.get_print_num(images,0)>=100000)522 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)523 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)524 525 def test_card83(self):526 absolute_path = os.path.join(os.getcwd(), 'card (83).png')527 images = cv2.imread(absolute_path)528 self.assertTrue(self.ocr.get_print_num(images,0)>=10000)529 self.assertTrue(self.ocr.get_print_num(images,1)>=100000)530 self.assertTrue(self.ocr.get_print_num(images,2)>=100000)531 532if __name__ == '__main__':...

Full Screen

Full Screen

static_route.py

Source:static_route.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*-coding:utf-8-*-3# @Time : 2017/11/1 ~ 2019/9/14# @Author : Allen Woo5import os6from flask import send_file, request, render_template, g7from werkzeug.exceptions import abort8from apps.app import csrf9from apps.configs.sys_config import ADMIN_STATIC_FOLDER, TEMP_STATIC_FOLDER10from apps.core.blueprint import static, theme_view, admin_static_file11from apps.core.flask.permission import page_permission_required12from apps.core.utils.get_config import get_config13from apps.modules.global_data.process.global_data import get_global_site_data14from apps.utils.format.obj_format import str_to_num15from apps.utils.image.image import ImageCompression16"""17 静态文件路由18 提示:19 1. static_size_img: 20 apps/static下图片路由: /static/<regex(r".*\..+"):path>21 参数w,h可指定图片大小22 2. theme_static:23 themes主题static下静态文件路由:/<theme name>/static/<regex(".*"):path>24 参数w,h可指定图片大小25"""26#####################################################27# apps/static静态文件路由28#####################################################29@csrf.exempt30@static.route('/<regex(".+"):path>', methods=['GET'])31@page_permission_required()32def static_file(path):33 """34 apps/static下静态文件获取(本视图函数只针对apps/static下的图片),apps/static下其他可以直接哟你flask默认的35 注意:图片获取路由(apps/static下)36 参数w,h可指定图片大小37 :param path:原图片路径38 :param w:获取的宽39 :param h:获取的高40 :return:w和h都大于0则返回相应尺寸图片; w和h都等于0则返回原图; 其中一个值大于0则返回以这个值为基础等比缩放图片41 """42 w = str_to_num(request.args.get("w", 0))43 h = str_to_num(request.args.get("h", 0))44 if w or h:45 path_list = os.path.splitext(path.rstrip().rstrip("/"))46 absolute_path = os.path.abspath("{}/{}_w_{}_h_{}{}".format(static.template_folder,47 path_list[0],48 w, h, path_list[1]))49 if not os.path.isfile(absolute_path):50 img_path = os.path.abspath(51 "{}/{}".format(static.template_folder, path))52 try:53 imgcs = ImageCompression(img_path, absolute_path)54 except BaseException:55 abort(404)56 if w and h:57 # 自定义长宽58 imgcs.custom_pixels(w, h)59 else:60 # 等比缩放61 imgcs.isometric(w, h)62 else:63 absolute_path = os.path.abspath(64 "{}/{}".format(static.template_folder, path))65 if not os.path.isfile(absolute_path):66 abort(404)67 absolute_path = banel_translate_js_files(68 prefix="static",69 route_relative_path=path,70 absolute_path=absolute_path71 )72 return send_file(filename_or_fp=absolute_path,73 conditional=True,74 last_modified=True)75#####################################################76# apps/admin_pages/下静态文件路由77#####################################################78@csrf.exempt79@admin_static_file.route('/<regex(".+"):path>', methods=['GET'])80@page_permission_required()81def admin_static_file(path):82 """83 获取admin_pages下静态文件84 :param path:文件路径85 """86 absolute_path = os.path.abspath("{}/{}".format(87 ADMIN_STATIC_FOLDER,88 path89 ))90 if not os.path.isfile(absolute_path):91 abort(404)92 absolute_path = banel_translate_js_files(93 prefix="adm_static_file",94 route_relative_path=path,95 absolute_path=absolute_path96 )97 return send_file(filename_or_fp=absolute_path,98 conditional=True,99 last_modified=True)100#####################################################101# apps/themes/下主题静态文件路由102#####################################################103@csrf.exempt104@theme_view.route('/theme/<theme_name>/static/<regex(".+"):path>', methods=['GET'])105@page_permission_required()106def theme_static_file(path, theme_name=None):107 """108 获取主题下静态文件109 注意:110 theme主题图片获取路由 (目录themes/<theme name>/static下图片)111 1.对于图片,本路由只能获取目录themes/<theme name>/static下定义尺寸图片112 参数w,h可指定图片大小113 :param path:原图片路径114 :param w: 获取的宽115 :param h: 获取的高116 :return:w和h都大于0则返回相应尺寸图片; w和h都等于0则返回原图; 其中一个值大于0则返回以这个值为基础等比缩放图片117 """118 if not theme_name:119 theme_name = get_config("theme", "CURRENT_THEME_NAME")120 w = str_to_num(request.args.get("w", 0))121 h = str_to_num(request.args.get("h", 0))122 if w or h:123 path_list = os.path.splitext(path.rstrip().rstrip("/"))124 absolute_path = os.path.abspath(125 "{}/{}/static/{}_w_{}_h_{}{}".format(126 theme_view.template_folder,127 theme_name,128 path_list[0],129 w,130 h,131 path_list[1]))132 if not os.path.isfile(absolute_path):133 img_path = os.path.abspath(134 "{}/{}/static/{}".format(135 theme_view.template_folder, theme_name, path))136 try:137 imgcs = ImageCompression(img_path, absolute_path)138 except BaseException:139 abort(404)140 if w and h:141 # 自定义长宽142 imgcs.custom_pixels(w, h)143 else:144 # 等比缩放145 imgcs.isometric(w, h)146 else:147 path = "{}/static/{}".format(theme_name, path)148 absolute_path = os.path.abspath("{}/{}".format(theme_view.template_folder, path))149 if not os.path.isfile(absolute_path):150 abort(404)151 absolute_path = banel_translate_js_files(152 prefix=theme_name,153 route_relative_path=path,154 absolute_path=absolute_path155 )156 return send_file(filename_or_fp=absolute_path,157 conditional=True,158 last_modified=True)159def banel_translate_js_files(prefix, route_relative_path, absolute_path):160 """161 Jinja2翻译js162 :param prefix:163 :param route_relative_path:164 :param absolute_path:165 :return:166 """167 if route_relative_path.endswith(".js"):168 # js 翻译169 ori_file_time = os.path.getmtime(absolute_path)170 name = os.path.split(route_relative_path)[-1]171 # 主题页面js或者以osr_开头的js文件给予翻译172 if "osr_page_js" in route_relative_path or name.startswith("osr-"):173 # 使用翻译好的js174 temp_name = "{}{}_{}".format(175 prefix,176 os.path.splitext(route_relative_path)[0].replace("/", "_"),177 g.site_global["language"]["current"])178 absolute_path = "{}/{}.js".format(TEMP_STATIC_FOLDER, temp_name)179 if not os.path.isfile(absolute_path):180 # 不存在翻译文件181 g.site_global = dict(g.site_global, **get_global_site_data(req_type="view"))182 data = dict(request.args.items())183 tr_content = render_template(route_relative_path, data=data)184 with open(absolute_path, "w") as wf:185 # flask中没找替换翻译js的Jinjia模块. 使用render_template来翻译js文件,186 wf.write(tr_content)187 else:188 tr_file_time = os.path.getmtime(absolute_path)189 if tr_file_time < ori_file_time:190 # 翻译文件的最后修改时间小于原文件191 g.site_global = dict(g.site_global, **get_global_site_data(req_type="view"))192 data = dict(request.args.items())193 tr_content = render_template(route_relative_path, data=data)194 with open(absolute_path, "w") as wf:195 # flask中没找替换翻译js的Jinjia模块. 使用render_template来翻译js文件,196 wf.write(tr_content)197 return absolute_path...

Full Screen

Full Screen

standard.py

Source:standard.py Github

copy

Full Screen

1import os2from os.path import isdir, isfile, join, basename3from django.conf import settings4from graphite.logger import log5from graphite.node import BranchNode, LeafNode6from graphite.readers import WhisperReader, GzippedWhisperReader, RRDReader7from graphite.util import find_escaped_pattern_fields8from . import fs_to_metric, get_real_metric_path, match_entries9class StandardFinder:10 DATASOURCE_DELIMETER = '::RRD_DATASOURCE::'11 def __init__(self, directories=None):12 directories = directories or settings.STANDARD_DIRS13 self.directories = directories14 def find_nodes(self, query):15 clean_pattern = query.pattern.replace('\\', '')16 pattern_parts = clean_pattern.split('.')17 for root_dir in self.directories:18 for absolute_path in self._find_paths(root_dir, pattern_parts):19 if basename(absolute_path).startswith('.'):20 continue21 if self.DATASOURCE_DELIMETER in basename(absolute_path):22 (absolute_path, datasource_pattern) = absolute_path.rsplit(self.DATASOURCE_DELIMETER, 1)23 else:24 datasource_pattern = None25 relative_path = absolute_path[ len(root_dir): ].lstrip('/')26 metric_path = fs_to_metric(relative_path)27 real_metric_path = get_real_metric_path(absolute_path, metric_path)28 metric_path_parts = metric_path.split('.')29 for field_index in find_escaped_pattern_fields(query.pattern):30 metric_path_parts[field_index] = pattern_parts[field_index].replace('\\', '')31 metric_path = '.'.join(metric_path_parts)32 # Now we construct and yield an appropriate Node object33 if isdir(absolute_path):34 yield BranchNode(metric_path)35 elif isfile(absolute_path):36 if absolute_path.endswith('.wsp') and WhisperReader.supported:37 reader = WhisperReader(absolute_path, real_metric_path)38 yield LeafNode(metric_path, reader)39 elif absolute_path.endswith('.wsp.gz') and GzippedWhisperReader.supported:40 reader = GzippedWhisperReader(absolute_path, real_metric_path)41 yield LeafNode(metric_path, reader)42 elif absolute_path.endswith('.rrd') and RRDReader.supported:43 if datasource_pattern is None:44 yield BranchNode(metric_path)45 else:46 for datasource_name in RRDReader.get_datasources(absolute_path):47 if match_entries([datasource_name], datasource_pattern):48 reader = RRDReader(absolute_path, datasource_name)49 yield LeafNode(metric_path + "." + datasource_name, reader)50 def _find_paths(self, current_dir, patterns):51 """Recursively generates absolute paths whose components underneath current_dir52 match the corresponding pattern in patterns"""53 pattern = patterns[0]54 patterns = patterns[1:]55 try:56 entries = os.listdir(current_dir)57 except OSError as e:58 log.exception(e) 59 entries = []60 subdirs = [e for e in entries if isdir( join(current_dir,e) )]61 matching_subdirs = match_entries(subdirs, pattern)62 if len(patterns) == 1 and RRDReader.supported: #the last pattern may apply to RRD data sources63 files = [e for e in entries if isfile( join(current_dir,e) )]64 rrd_files = match_entries(files, pattern + ".rrd")65 if rrd_files: #let's assume it does66 datasource_pattern = patterns[0]67 for rrd_file in rrd_files:68 absolute_path = join(current_dir, rrd_file)69 yield absolute_path + self.DATASOURCE_DELIMETER + datasource_pattern70 if patterns: #we've still got more directories to traverse71 for subdir in matching_subdirs:72 absolute_path = join(current_dir, subdir)73 for match in self._find_paths(absolute_path, patterns):74 yield match75 else: #we've got the last pattern76 files = [e for e in entries if isfile( join(current_dir,e) )]77 matching_files = match_entries(files, pattern + '.*')78 for basename in matching_files + matching_subdirs:...

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 autotest 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