Best Python code snippet using avocado_python
test_import_scanning.py
Source:test_import_scanning.py
1import logging2import pytest3from pathlib import Path4from _comrad.package.import_scanning import (scan_py_imports, scan_ui_imports, ScannedImport, normalize_imports,5 scan_imports)6from _comrad_examples import examples7@pytest.fixture8def ensure_acc_py(monkeypatch):9 def wrapper(active: bool):10 if active:11 monkeypatch.setenv('ACC_PYTHON_ACTIVE', '1')12 else:13 monkeypatch.delenv('ACC_PYTHON_ACTIVE', raising=False)14 return wrapper15@pytest.mark.parametrize('relative_loc', [None, 'relative_dir', 'relative_dir', 'relative_dir/relative_subdir'])16@pytest.mark.parametrize('code,expected_imports', [17 ('', []),18 ('print("Nothing important")', []),19 ('import pytest', ['pytest']),20 ('import comrad', ['comrad']),21 ('import numpy as np', ['numpy']),22 ('import _comrad', ['_comrad']),23 ('from . import sibling', []),24 ('from .. import cousin', []),25 ('from .sibling import anything', []),26 ('from comrad import CDisplay', ['comrad']),27 ('from comrad import CDisplay as ComradDisplay', ['comrad']),28 ('from comrad.widgets import CDisplay', ['comrad.widgets']),29 ("""from comrad.widgets import CDisplay30import logging31from pytest import mark""", ['comrad.widgets', 'logging', 'pytest']),32 ("""from comrad import CDisplay33class MyDisplay(CDisplay):34 pass35""", ['comrad']),36 ("""from comrad import CDisplay37class MyDisplay(CDisplay):38 import pytest39""", ['comrad', 'pytest']),40 ("""from comrad import CDisplay41class MyDisplay(CDisplay):42 from .sibling import anything""", ['comrad']),43 ("""import logging44# import anything_else45""", ['logging']),46])47def test_scan_py_imports_succeed(tmp_path: Path, code, expected_imports, relative_loc):48 code_file = tmp_path / 'test_file.py'49 code_file.write_text(code)50 expected_pkgs = {ScannedImport.create(pkg=i, relative_loc=relative_loc) for i in expected_imports}51 assert scan_py_imports(code_file, relative_loc=relative_loc) == expected_pkgs52@pytest.mark.parametrize('relative_loc', [None, '', 'relative_dir', 'relative_dir/relative_subdir'])53@pytest.mark.parametrize('code', [54 'import',55 'import .sibling.stuff',56 'from import stuff',57 """from comrad import CDisplay58class MyDisplay(CDisplay):""",59])60def test_scan_py_imports_fails(tmp_path: Path, code, relative_loc):61 code_file = tmp_path / 'test_file.py'62 code_file.write_text(code)63 with pytest.raises(SyntaxError):64 scan_py_imports(code_file, relative_loc=relative_loc)65@pytest.mark.parametrize('relative_loc', [None, '', 'relative_dir', 'relative_dir/relative_subdir'])66@pytest.mark.parametrize('xml,expected_imports', [67 ("""<?xml version="1.0" encoding="UTF-8"?>68<ui version="4.0">69 <widget class="QWidget" name="Form" />70</ui>""", []),71 ("""<?xml version="1.0" encoding="UTF-8"?>72<ui version="4.0">73 <widget class="QWidget" name="Form" />74 <customwidgets>75 <customwidget>76 <class>MyLabel</class>77 <extends>QLabel</extends>78 <header>custom_widget</header>79 </customwidget>80 <customwidget>81 <class>AnotherLabel</class>82 <extends>QLabel</extends>83 <header>subdir/another_widget.h</header>84 </customwidget>85 <customwidget>86 <class>ThirdLabel</class>87 <extends>QLabel</extends>88 <header>subdir.another_widget</header>89 </customwidget>90 <customwidget>91 <class>ForthLabel</class>92 <extends>QLabel</extends>93 <header>subdir/subdir2/another_widget.h</header>94 </customwidget>95 <customwidget>96 <class>FifthLabel</class>97 <extends>QLabel</extends>98 <header>subdir/subdir2/another_widget</header>99 </customwidget>100 <customwidget>101 <class>SixthLabel</class>102 <extends>QLabel</extends>103 <header>subdir.subdir2.another_widget</header>104 </customwidget>105 </customwidgets>106</ui>""", ['custom_widget', 'subdir.another_widget', 'subdir.subdir2.another_widget']),107 ("""<?xml version="1.0" encoding="UTF-8"?>108<ui version="4.0">109 <class>Form</class>110 <widget class="QWidget" name="Form">111 <property name="geometry">112 <rect>113 <x>0</x>114 <y>0</y>115 <width>294</width>116 <height>87</height>117 </rect>118 </property>119 <property name="windowTitle">120 <string>Client-side transformations with Python</string>121 </property>122 <layout class="QHBoxLayout" name="horizontalLayout">123 <item>124 <widget class="CLabel" name="CLabel">125 <property name="channel" stdset="0">126 <string notr="true">DemoDevice/Acquisition#Demo</string>127 </property>128 <property name="valueTransformation">129 <string notr="true">output(f'<<{new_val}>> - from {__file__}')</string>130 </property>131 </widget>132 </item>133 </layout>134 </widget>135 <customwidgets>136 <customwidget>137 <class>PyDMLabel</class>138 <extends>QLabel</extends>139 <header>pydm.widgets.label</header>140 </customwidget>141 <customwidget>142 <class>CLabel</class>143 <extends>PyDMLabel</extends>144 <header>comrad.widgets.indicators</header>145 </customwidget>146 </customwidgets>147 <resources/>148 <connections/>149</ui>""", ['pydm.widgets.label', 'comrad.widgets.indicators']),150 ("""<?xml version="1.0" encoding="UTF-8"?>151<ui version="4.0">152 <widget class="CLabel" name="CLabel_3">153 <property name="valueTransformation">154 <string notr="true">from imported import decorate155output(decorate(new_val))</string>156 </property>157 </widget>158 <customwidgets>159 <customwidget>160 <class>PyDMLabel</class>161 <extends>QLabel</extends>162 <header>pydm.widgets.label</header>163 </customwidget>164 <customwidget>165 <class>CLabel</class>166 <extends>PyDMLabel</extends>167 <header>comrad.widgets.indicators</header>168 </customwidget>169 </customwidgets>170 <resources/>171 <connections/>172</ui>""", ['imported', 'comrad.widgets.indicators', 'pydm.widgets.label']),173 ("""<?xml version="1.0" encoding="UTF-8"?>174<ui version="4.0">175 <widget class="CLabel" name="CLabel_3">176 <property name="valueTransformation">177 <string notr="true">import numpy as np</string>178 </property>179 </widget>180 <customwidgets>181 <customwidget>182 <class>PyDMLabel</class>183 <extends>QLabel</extends>184 <header>pydm.widgets.label</header>185 </customwidget>186 <customwidget>187 <class>CLabel</class>188 <extends>PyDMLabel</extends>189 <header>comrad.widgets.indicators</header>190 </customwidget>191 </customwidgets>192 <resources/>193 <connections/>194</ui>""", ['numpy', 'comrad.widgets.indicators', 'pydm.widgets.label']),195 ("""<?xml version="1.0" encoding="UTF-8"?>196<ui version="4.0">197 <class>Form</class>198 <widget class="QWidget" name="Form">199 <property name="geometry">200 <rect>201 <x>0</x>202 <y>0</y>203 <width>294</width>204 <height>87</height>205 </rect>206 </property>207 <property name="windowTitle">208 <string>Client-side transformations with Python</string>209 </property>210 <layout class="QHBoxLayout" name="horizontalLayout">211 <item>212 <widget class="CLabel" name="CLabel">213 <property name="channel" stdset="0">214 <string notr="true">DemoDevice/Acquisition#Demo</string>215 </property>216 <property name="valueTransformation">217 <string notr="true">import numpy as np</string>218 </property>219 </widget>220 </item>221 </layout>222 </widget>223 <customwidgets>224 <customwidget>225 <class>PyDMLabel</class>226 <extends>QLabel</extends>227 <header>pydm.widgets.label</header>228 </customwidget>229 <customwidget>230 <class>CLabel</class>231 <extends>PyDMLabel</extends>232 <header>comrad.widgets.indicators</header>233 </customwidget>234 </customwidgets>235 <resources/>236 <connections/>237</ui>""", ['numpy', 'pydm.widgets.label', 'comrad.widgets.indicators']),238])239def test_scan_ui_imports_succeeds(tmp_path: Path, xml, expected_imports, relative_loc):240 ui_file = tmp_path / 'test_file.ui'241 ui_file.write_text(xml)242 expected_pkgs = {ScannedImport.create(pkg=i, relative_loc=relative_loc) for i in expected_imports}243 assert scan_ui_imports(ui_file, relative_loc=relative_loc) == expected_pkgs244@pytest.mark.parametrize('relative_loc,filename,code,expected_imports', [245 (None, 'external.py', '', []),246 ('', 'external.py', '', []),247 ('relative_dir', 'external.py', '', []),248 ('relative_dir/relative_subdir', 'external.py', '', []),249 (None, 'rel1/external.py', '', []),250 ('', 'rel1/external.py', '', []),251 ('relative_dir', 'rel1/external.py', '', []),252 ('relative_dir/relative_subdir', 'rel1/external.py', '', []),253 (None, 'external.py', 'print("Nothing important")', []),254 ('', 'external.py', 'print("Nothing important")', []),255 ('relative_dir', 'external.py', 'print("Nothing important")', []),256 ('relative_dir/relative_subdir', 'external.py', 'print("Nothing important")', []),257 (None, 'rel1/external.py', 'print("Nothing important")', []),258 ('', 'rel1/external.py', 'print("Nothing important")', []),259 ('relative_dir', 'rel1/external.py', 'print("Nothing important")', []),260 ('relative_dir/relative_subdir', 'rel1/external.py', 'print("Nothing important")', []),261 (None, 'external.py', 'import pytest', [('pytest', None)]),262 ('', 'external.py', 'import pytest', [('pytest', None)]),263 ('relative_dir', 'external.py', 'import pytest', [('pytest', 'relative_dir')]),264 ('relative_dir/relative_subdir', 'external.py', 'import pytest', [('pytest', 'relative_dir.relative_subdir')]),265 (None, 'rel1/external.py', 'import pytest', [('pytest', 'rel1')]),266 ('', 'rel1/external.py', 'import pytest', [('pytest', 'rel1')]),267 ('relative_dir', 'rel1/external.py', 'import pytest', [('pytest', 'relative_dir.rel1')]),268 ('relative_dir/relative_subdir', 'rel1/external.py', 'import pytest', [('pytest', 'relative_dir.relative_subdir.rel1')]),269 (None, 'external.py', 'import _comrad', [('_comrad', None)]),270 ('', 'external.py', 'import _comrad', [('_comrad', None)]),271 ('relative_dir', 'external.py', 'import _comrad', [('_comrad', 'relative_dir')]),272 ('relative_dir/relative_subdir', 'external.py', 'import _comrad', [('_comrad', 'relative_dir.relative_subdir')]),273 (None, 'rel1/external.py', 'import _comrad', [('_comrad', 'rel1')]),274 ('', 'rel1/external.py', 'import _comrad', [('_comrad', 'rel1')]),275 ('relative_dir', 'rel1/external.py', 'import _comrad', [('_comrad', 'relative_dir.rel1')]),276 ('relative_dir/relative_subdir', 'rel1/external.py', 'import _comrad', [('_comrad', 'relative_dir.relative_subdir.rel1')]),277 (None, 'external.py', 'from . import sibling', []),278 ('', 'external.py', 'from . import sibling', []),279 ('relative_dir', 'external.py', 'from . import sibling', []),280 ('relative_dir/relative_subdir', 'external.py', 'from . import sibling', []),281 (None, 'rel1/external.py', 'from . import sibling', []),282 ('', 'rel1/external.py', 'from . import sibling', []),283 ('relative_dir', 'rel1/external.py', 'from . import sibling', []),284 ('relative_dir/relative_subdir', 'rel1/external.py', 'from . import sibling', []),285 (None, 'external.py', 'from .. import cousin', []),286 ('', 'external.py', 'from .. import cousin', []),287 ('relative_dir', 'external.py', 'from .. import cousin', []),288 ('relative_dir/relative_subdir', 'external.py', 'from .. import cousin', []),289 (None, 'rel1/external.py', 'from .. import cousin', []),290 ('', 'rel1/external.py', 'from .. import cousin', []),291 ('relative_dir', 'rel1/external.py', 'from .. import cousin', []),292 ('relative_dir/relative_subdir', 'rel1/external.py', 'from .. import cousin', []),293 (None, 'external.py', 'from .sibling import anything', []),294 ('', 'external.py', 'from .sibling import anything', []),295 ('relative_dir', 'external.py', 'from .sibling import anything', []),296 ('relative_dir/relative_subdir', 'external.py', 'from .sibling import anything', []),297 (None, 'rel1/external.py', 'from .sibling import anything', []),298 ('', 'rel1/external.py', 'from .sibling import anything', []),299 ('relative_dir', 'rel1/external.py', 'from .sibling import anything', []),300 ('relative_dir/relative_subdir', 'rel1/external.py', 'from .sibling import anything', []),301 (None, 'external.py', 'from comrad import CDisplay', [('comrad', None)]),302 ('', 'external.py', 'from comrad import CDisplay', [('comrad', None)]),303 ('relative_dir', 'external.py', 'from comrad import CDisplay', [('comrad', 'relative_dir')]),304 ('relative_dir/relative_subdir', 'external.py', 'from comrad import CDisplay', [('comrad', 'relative_dir.relative_subdir')]),305 (None, 'rel1/external.py', 'from comrad import CDisplay', [('comrad', 'rel1')]),306 ('', 'rel1/external.py', 'from comrad import CDisplay', [('comrad', 'rel1')]),307 ('relative_dir', 'rel1/external.py', 'from comrad import CDisplay', [('comrad', 'relative_dir.rel1')]),308 ('relative_dir/relative_subdir', 'rel1/external.py', 'from comrad import CDisplay', [('comrad', 'relative_dir.relative_subdir.rel1')]),309 (None, 'external.py', 'from comrad.widgets import CDisplay', [('comrad.widgets', None)]),310 ('', 'external.py', 'from comrad.widgets import CDisplay', [('comrad.widgets', None)]),311 ('relative_dir', 'external.py', 'from comrad.widgets import CDisplay', [('comrad.widgets', 'relative_dir')]),312 ('relative_dir/relative_subdir', 'external.py', 'from comrad.widgets import CDisplay', [('comrad.widgets', 'relative_dir.relative_subdir')]),313 (None, 'rel1/external.py', 'from comrad.widgets import CDisplay', [('comrad.widgets', 'rel1')]),314 ('', 'rel1/external.py', 'from comrad.widgets import CDisplay', [('comrad.widgets', 'rel1')]),315 ('relative_dir', 'rel1/external.py', 'from comrad.widgets import CDisplay', [('comrad.widgets', 'relative_dir.rel1')]),316 ('relative_dir/relative_subdir', 'rel1/external.py', 'from comrad.widgets import CDisplay', [('comrad.widgets', 'relative_dir.relative_subdir.rel1')]),317 (None, 'external.py', """from comrad.widgets import CDisplay318import logging319from pytest import mark""", [('comrad.widgets', None), ('logging', None), ('pytest', None)]),320 ('', 'external.py', """from comrad.widgets import CDisplay321import logging322from pytest import mark""", [('comrad.widgets', None), ('logging', None), ('pytest', None)]),323 ('relative_dir', 'external.py', """from comrad.widgets import CDisplay324import logging325from pytest import mark""", [('comrad.widgets', 'relative_dir'), ('logging', 'relative_dir'), ('pytest', 'relative_dir')]),326 ('relative_dir/relative_subdir', 'external.py', """from comrad.widgets import CDisplay327import logging328from pytest import mark""", [('comrad.widgets', 'relative_dir.relative_subdir'), ('logging', 'relative_dir.relative_subdir'), ('pytest', 'relative_dir.relative_subdir')]),329 (None, 'rel1/external.py', """from comrad.widgets import CDisplay330import logging331from pytest import mark""", [('comrad.widgets', 'rel1'), ('logging', 'rel1'), ('pytest', 'rel1')]),332 ('', 'rel1/external.py', """from comrad.widgets import CDisplay333import logging334from pytest import mark""", [('comrad.widgets', 'rel1'), ('logging', 'rel1'), ('pytest', 'rel1')]),335 ('relative_dir', 'rel1/external.py', """from comrad.widgets import CDisplay336import logging337from pytest import mark""", [('comrad.widgets', 'relative_dir.rel1'), ('logging', 'relative_dir.rel1'), ('pytest', 'relative_dir.rel1')]),338 ('relative_dir/relative_subdir', 'rel1/external.py', """from comrad.widgets import CDisplay339import logging340from pytest import mark""", [('comrad.widgets', 'relative_dir.relative_subdir.rel1'), ('logging', 'relative_dir.relative_subdir.rel1'), ('pytest', 'relative_dir.relative_subdir.rel1')]),341])342def test_scan_ui_imports_succeeds_with_external_referenced_file(tmp_path: Path, relative_loc, code,343 expected_imports, filename):344 ui_file = tmp_path / 'test_file.ui'345 ui_file.write_text(f"""<?xml version="1.0" encoding="UTF-8"?>346<ui version="4.0">347 <widget class="CLabel" name="CLabel">348 <property name="snippetFilename" stdset="0">349 <string>{filename}</string>350 </property>351 </widget>352</ui>""")353 filename_path = Path(filename)354 py_file = tmp_path / filename_path355 py_file.parent.mkdir(parents=True, exist_ok=True)356 py_file.write_text(code)357 expected_pkgs = {ScannedImport.create(pkg=i, relative_loc=l) for i, l in expected_imports}358 actual_pkgs = scan_ui_imports(ui_file, relative_loc=relative_loc)359 assert actual_pkgs == expected_pkgs360@pytest.mark.parametrize('relative_loc', [None, '', 'relative_dir', 'relative_dir/relative_subdir'])361def test_scan_ui_imports_with_external_referenced_file_warns_if_does_not_exist(tmp_path: Path, relative_loc,362 log_capture):363 referenced_file_name = 'test_file.py'364 ui_file = tmp_path / 'test_file.ui'365 ui_file.write_text(f"""<?xml version="1.0" encoding="UTF-8"?>366<ui version="4.0">367 <widget class="CLabel" name="CLabel">368 <property name="snippetFilename" stdset="0">369 <string>{referenced_file_name}</string>370 </property>371 </widget>372</ui>""")373 assert not (tmp_path / referenced_file_name).exists()374 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == []375 actual_pkgs = scan_ui_imports(ui_file, relative_loc=relative_loc)376 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == [f'Indicated file {referenced_file_name} inside '377 f"{ui_file!s}'s snippetFilename cannot be opened"]378 assert actual_pkgs == set()379@pytest.mark.parametrize('relative_loc', [None, '', 'relative_dir', 'relative_dir/relative_subdir'])380def test_scan_ui_imports_with_external_referenced_file_warns_if_is_dir(tmp_path: Path, relative_loc,381 log_capture):382 referenced_file_name = 'test_file.py'383 ui_file = tmp_path / 'test_file.ui'384 ui_file.write_text(f"""<?xml version="1.0" encoding="UTF-8"?>385<ui version="4.0">386 <widget class="CLabel" name="CLabel">387 <property name="snippetFilename" stdset="0">388 <string>{referenced_file_name}</string>389 </property>390 </widget>391</ui>""")392 (tmp_path / referenced_file_name).mkdir(parents=True)393 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == []394 actual_pkgs = scan_ui_imports(ui_file, relative_loc=relative_loc)395 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == [f'Indicated file {referenced_file_name} inside '396 f"{ui_file!s}'s snippetFilename cannot be opened"]397 assert actual_pkgs == set()398@pytest.mark.parametrize('relative_loc', [None, '', 'relative_dir', 'relative_dir/relative_subdir'])399@pytest.mark.parametrize('referenced_file_name,code,expected_warning', [400 ('test_file.py', 'import', "Indicated file test_file.py inside {ui_file}'s snippetFilename contains invalid Python syntax:"),401 ('test_file.py', 'import .sibling.stuff', "Indicated file test_file.py inside {ui_file}'s snippetFilename contains invalid Python syntax:"),402 ('test_file.py', 'from import stuff', "Indicated file test_file.py inside {ui_file}'s snippetFilename contains invalid Python syntax:"),403 ('test_file.py', """from comrad import CDisplay404class MyDisplay(CDisplay):""", "Indicated file test_file.py inside {ui_file}'s snippetFilename contains invalid Python syntax:"),405])406def test_scan_ui_imports_with_external_referenced_file_warns_if_cant_be_parsed(tmp_path: Path, relative_loc,407 referenced_file_name, expected_warning,408 log_capture, code):409 ui_file = tmp_path / 'test_file.ui'410 ui_file.write_text(f"""<?xml version="1.0" encoding="UTF-8"?>411<ui version="4.0">412 <widget class="CLabel" name="CLabel">413 <property name="snippetFilename" stdset="0">414 <string>{referenced_file_name}</string>415 </property>416 </widget>417</ui>""")418 (tmp_path / referenced_file_name).write_text(code)419 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == []420 actual_pkgs = scan_ui_imports(ui_file, relative_loc=relative_loc)421 logs = log_capture(logging.WARNING, '_comrad.package.import_scanning')422 assert len(logs) == 1423 assert expected_warning.format(ui_file=str(ui_file)) in logs[0]424 assert actual_pkgs == set()425@pytest.mark.parametrize('relative_loc', [None, '', 'relative_dir', 'relative_dir/relative_subdir'])426@pytest.mark.parametrize('xml,expected_error', [427 ('', '{ui_file} cannot be parsed as XML: no element found: line 1, column 0'),428 ('<ui version="4.0">', '{ui_file} cannot be parsed as XML: no element found: line 1, column 18'),429 ("""<?xml version="1.0" encoding="UTF-8"?>430<ui version="4.0">431 <widget class="CLabel" name="CLabel">432 <property name="snippetFilename" stdset="0">433 <string>test</string>434 </widget>435</ui>""", '{ui_file} cannot be parsed as XML: mismatched tag: line 6, column 3'),436 ("""<?xml version="1.0" encoding="UTF-8"?>437<ui version="4.0">438 <widget class="CLabel" name="CLabel">439 <property name="valueTransformation" stdset="0">440 <string>import; import numpy</string>441 </property>442 </widget>443</ui>""", 'valueTransformation "import; import numpy" inside {ui_file} contains invalid Python syntax: invalid syntax (<unknown>, line 1)'),444])445def test_scan_ui_imports_fails(tmp_path: Path, xml, relative_loc, log_capture, expected_error):446 ui_file = tmp_path / 'test_file.ui'447 ui_file.write_text(xml)448 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == []449 actual_pkgs = scan_ui_imports(ui_file, relative_loc=relative_loc)450 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == [expected_error.format(ui_file=str(ui_file))]451 assert actual_pkgs == set()452@pytest.mark.parametrize('acc_py_active,relative_loc,found_imports,local_modules,expected_results', [453 (True, None, set(), set(), set()),454 (True, None, {'one', 'one.two.three'}, set(), {'one'}),455 (True, None, {'one', 'one.two.three', 'logging'}, set(), {'one'}),456 (True, None, {'one', 'one.two.three', 'PyQt5.QtWidgets'}, set(), {'one'}),457 (True, None, {'one', 'one.two.three', 'qtpy.QtWidgets'}, set(), {'one', 'qtpy'}),458 (True, None, {'one', 'one.two.three', 'numpy'}, set(), {'one', 'numpy'}),459 (True, None, {'one', 'one.two.three', 'pytest'}, set(), {'one', 'pytest'}),460 (True, None, {'one', 'one.two.three', 'logging', 'pytest'}, set(), {'one', 'pytest'}),461 (True, None, {'one', 'one.two.three', 'logging', 'pytest', 'PyQt5'}, set(), {'one', 'pytest'}),462 (True, None, {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, set(), {'one', 'pytest', 'numpy'}),463 (True, None, {'one'}, {'one'}, set()),464 (True, None, {'one', 'logging'}, {'one'}, set()),465 (True, None, {'one', 'PyQt5.QtWidgets'}, {'one'}, set()),466 (True, None, {'one', 'qtpy.QtWidgets'}, {'one'}, {'qtpy'}),467 (True, None, {'one', 'numpy'}, {'one'}, {'numpy'}),468 (True, None, {'one', 'pytest'}, {'one'}, {'pytest'}),469 (True, None, {'one', 'logging', 'pytest'}, {'one'}, {'pytest'}),470 (True, None, {'mypkg'}, {'mypkg_metadata'}, {'mypkg'}),471 (True, None, {'mypkg'}, {'mypkg.metadata'}, set()),472 (True, None, {'one', 'one.two.three'}, {'one.two.three'}, set()),473 (True, None, {'one', 'one.two.three', 'logging'}, {'one.two.three'}, set()),474 (True, None, {'one', 'one.two.three', 'PyQt5.QtWidgets'}, {'one.two.three'}, set()),475 (True, None, {'one', 'one.two.three', 'qtpy.QtWidgets'}, {'one.two.three'}, {'qtpy'}),476 (True, None, {'one', 'one.two.three', 'numpy'}, {'one.two.three'}, {'numpy'}),477 (True, None, {'one', 'one.two.three', 'pytest'}, {'one.two.three'}, {'pytest'}),478 (True, None, {'one', 'one.two.three', 'logging', 'pytest'}, {'one.two.three'}, {'pytest'}),479 (True, None, {'one.two.three'}, {'one.two.three'}, set()),480 (True, None, {'one.two.three', 'logging'}, {'one.two.three'}, set()),481 (True, None, {'one.two.three', 'PyQt5.QtWidgets'}, {'one.two.three'}, set()),482 (True, None, {'one.two.three', 'qtpy.QtWidgets'}, {'one.two.three'}, {'qtpy'}),483 (True, None, {'one.two.three', 'numpy'}, {'one.two.three'}, {'numpy'}),484 (True, None, {'one.two.three', 'pytest'}, {'one.two.three'}, {'pytest'}),485 (True, None, {'one.two.three', 'logging', 'pytest'}, {'one.two.three'}, {'pytest'}),486 (True, '', set(), set(), set()),487 (True, '', {'one', 'one.two.three'}, set(), {'one'}),488 (True, '', {'one', 'one.two.three', 'logging'}, set(), {'one'}),489 (True, '', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, set(), {'one'}),490 (True, '', {'one', 'one.two.three', 'qtpy.QtWidgets'}, set(), {'one', 'qtpy'}),491 (True, '', {'one', 'one.two.three', 'pytest'}, set(), {'one', 'pytest'}),492 (True, '', {'one', 'one.two.three', 'numpy'}, set(), {'one', 'numpy'}),493 (True, '', {'one', 'one.two.three', 'logging', 'pytest'}, set(), {'one', 'pytest'}),494 (True, '', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, set(), {'one', 'pytest', 'numpy'}),495 (True, '', {'one'}, {'one'}, set()),496 (True, '', {'one', 'logging'}, {'one'}, set()),497 (True, '', {'one', 'PyQt5.QtWidgets'}, {'one'}, set()),498 (True, '', {'one', 'qtpy.QtWidgets'}, {'one'}, {'qtpy'}),499 (True, '', {'one', 'numpy'}, {'one'}, {'numpy'}),500 (True, '', {'one', 'pytest'}, {'one'}, {'pytest'}),501 (True, '', {'one', 'logging', 'pytest'}, {'one'}, {'pytest'}),502 (True, '', {'one', 'logging', 'pytest', 'numpy'}, {'one'}, {'pytest', 'numpy'}),503 (True, '', {'mypkg'}, {'mypkg_metadata'}, {'mypkg'}),504 (True, '', {'mypkg'}, {'mypkg.metadata'}, set()),505 (True, '', {'one', 'one.two.three'}, {'one.two.three'}, set()),506 (True, '', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, {'one.two.three'}, set()),507 (True, '', {'one', 'one.two.three', 'logging'}, {'one.two.three'}, set()),508 (True, '', {'one', 'one.two.three', 'qtpy.QtWidgets'}, {'one.two.three'}, {'qtpy'}),509 (True, '', {'one', 'one.two.three', 'numpy'}, {'one.two.three'}, {'numpy'}),510 (True, '', {'one', 'one.two.three', 'pytest'}, {'one.two.three'}, {'pytest'}),511 (True, '', {'one', 'one.two.three', 'logging', 'pytest'}, {'one.two.three'}, {'pytest'}),512 (True, '', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, {'one.two.three'}, {'pytest', 'numpy'}),513 (True, '', {'one.two.three'}, {'one.two.three'}, set()),514 (True, '', {'one.two.three', 'logging'}, {'one.two.three'}, set()),515 (True, '', {'one.two.three', 'PyQt5.QtWidgets'}, {'one.two.three'}, set()),516 (True, '', {'one.two.three', 'qtpy.QtWidgets'}, {'one.two.three'}, {'qtpy'}),517 (True, '', {'one.two.three', 'pytest'}, {'one.two.three'}, {'pytest'}),518 (True, '', {'one.two.three', 'numpy'}, {'one.two.three'}, {'numpy'}),519 (True, '', {'one.two.three', 'logging', 'pytest'}, {'one.two.three'}, {'pytest'}),520 (True, '', {'one.two.three', 'logging', 'pytest', 'numpy'}, {'one.two.three'}, {'pytest', 'numpy'}),521 (True, 'relative_dir', set(), set(), set()),522 (True, 'relative_dir', {'one', 'one.two.three'}, set(), {'one'}),523 (True, 'relative_dir', {'one', 'one.two.three', 'logging'}, set(), {'one'}),524 (True, 'relative_dir', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, set(), {'one'}),525 (True, 'relative_dir', {'one', 'one.two.three', 'qtpy.QtWidgets'}, set(), {'one', 'qtpy'}),526 (True, 'relative_dir', {'one', 'one.two.three', 'pytest'}, set(), {'one', 'pytest'}),527 (True, 'relative_dir', {'one', 'one.two.three', 'logging', 'pytest'}, set(), {'one', 'pytest'}),528 (True, 'relative_dir', {'one'}, {'relative_dir.one'}, set()),529 (True, 'relative_dir', {'one', 'logging'}, {'relative_dir.one'}, set()),530 (True, 'relative_dir', {'one', 'PyQt5.QtWidgets'}, {'relative_dir.one'}, set()),531 (True, 'relative_dir', {'one', 'qtpy.QtWidgets'}, {'relative_dir.one'}, {'qtpy'}),532 (True, 'relative_dir', {'one', 'pytest'}, {'relative_dir.one'}, {'pytest'}),533 (True, 'relative_dir', {'one', 'numpy'}, {'relative_dir.one'}, {'numpy'}),534 (True, 'relative_dir', {'one', 'logging', 'pytest'}, {'relative_dir.one'}, {'pytest'}),535 (True, 'relative_dir', {'one', 'logging', 'pytest', 'numpy'}, {'relative_dir.one'}, {'pytest', 'numpy'}),536 (True, 'relative_dir', {'mypkg'}, {'relative_dir.mypkg_metadata'}, {'mypkg'}),537 (True, 'relative_dir', {'mypkg'}, {'relative_dir.mypkg.metadata'}, set()),538 (True, 'relative_dir', {'one', 'one.two.three'}, {'relative_dir.one.two.three'}, set()),539 (True, 'relative_dir', {'one', 'one.two.three', 'logging'}, {'relative_dir.one.two.three'}, set()),540 (True, 'relative_dir', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, {'relative_dir.one.two.three'}, set()),541 (True, 'relative_dir', {'one', 'one.two.three', 'qtpy.QtWidgets'}, {'relative_dir.one.two.three'}, {'qtpy'}),542 (True, 'relative_dir', {'one', 'one.two.three', 'pytest'}, {'relative_dir.one.two.three'}, {'pytest'}),543 (True, 'relative_dir', {'one', 'one.two.three', 'numpy'}, {'relative_dir.one.two.three'}, {'numpy'}),544 (True, 'relative_dir', {'one', 'one.two.three', 'logging', 'pytest'}, {'relative_dir.one.two.three'}, {'pytest'}),545 (True, 'relative_dir', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, {'relative_dir.one.two.three'}, {'pytest', 'numpy'}),546 (True, 'relative_dir', {'one.two.three'}, {'relative_dir.one.two.three'}, set()),547 (True, 'relative_dir', {'one.two.three', 'logging'}, {'relative_dir.one.two.three'}, set()),548 (True, 'relative_dir', {'one.two.three', 'PyQt5.QtWidgets'}, {'relative_dir.one.two.three'}, set()),549 (True, 'relative_dir', {'one.two.three', 'qtpy.QtWidgets'}, {'relative_dir.one.two.three'}, {'qtpy'}),550 (True, 'relative_dir', {'one.two.three', 'pytest'}, {'relative_dir.one.two.three'}, {'pytest'}),551 (True, 'relative_dir', {'one.two.three', 'numpy'}, {'relative_dir.one.two.three'}, {'numpy'}),552 (True, 'relative_dir', {'one.two.three', 'logging', 'pytest'}, {'relative_dir.one.two.three'}, {'pytest'}),553 (True, 'relative_dir', {'one.two.three', 'logging', 'pytest', 'numpy'}, {'relative_dir.one.two.three'}, {'pytest', 'numpy'}),554 (True, 'relative_dir/relative_subdir', set(), set(), set()),555 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three'}, set(), {'one'}),556 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging'}, set(), {'one'}),557 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, set(), {'one'}),558 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'qtpy.QtWidgets'}, set(), {'one', 'qtpy'}),559 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'pytest'}, set(), {'one', 'pytest'}),560 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'numpy'}, set(), {'one', 'numpy'}),561 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging', 'pytest'}, set(), {'one', 'pytest'}),562 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, set(), {'one', 'pytest', 'numpy'}),563 (True, 'relative_dir/relative_subdir', {'one'}, {'relative_dir.relative_subdir.one'}, set()),564 (True, 'relative_dir/relative_subdir', {'one', 'logging'}, {'relative_dir.relative_subdir.one'}, set()),565 (True, 'relative_dir/relative_subdir', {'one', 'PyQt5.QtWidgets'}, {'relative_dir.relative_subdir.one'}, set()),566 (True, 'relative_dir/relative_subdir', {'one', 'qtpy.QtWidgets'}, {'relative_dir.relative_subdir.one'}, {'qtpy'}),567 (True, 'relative_dir/relative_subdir', {'one', 'pytest'}, {'relative_dir.relative_subdir.one'}, {'pytest'}),568 (True, 'relative_dir/relative_subdir', {'one', 'numpy'}, {'relative_dir.relative_subdir.one'}, {'numpy'}),569 (True, 'relative_dir/relative_subdir', {'one', 'logging', 'pytest'}, {'relative_dir.relative_subdir.one'}, {'pytest'}),570 (True, 'relative_dir/relative_subdir', {'one', 'logging', 'pytest', 'numpy'}, {'relative_dir.relative_subdir.one'}, {'pytest', 'numpy'}),571 (True, 'relative_dir/relative_subdir', {'mypkg'}, {'relative_dir.relative_subdir.mypkg_metadata'}, {'mypkg'}),572 (True, 'relative_dir/relative_subdir', {'mypkg'}, {'relative_dir.relative_subdir.mypkg.metadata'}, set()),573 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three'}, {'relative_dir.relative_subdir.one.two.three'}, set()),574 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging'}, {'relative_dir.relative_subdir.one.two.three'}, set()),575 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, {'relative_dir.relative_subdir.one.two.three'}, set()),576 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'qtpy.QtWidgets'}, {'relative_dir.relative_subdir.one.two.three'}, {'qtpy'}),577 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'pytest'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest'}),578 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'numpy'}, {'relative_dir.relative_subdir.one.two.three'}, {'numpy'}),579 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging', 'pytest'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest'}),580 (True, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest', 'numpy'}),581 (True, 'relative_dir/relative_subdir', {'one.two.three'}, {'relative_dir.relative_subdir.one.two.three'}, set()),582 (True, 'relative_dir/relative_subdir', {'one.two.three', 'logging'}, {'relative_dir.relative_subdir.one.two.three'}, set()),583 (True, 'relative_dir/relative_subdir', {'one.two.three', 'PyQt5.QtWidgets'}, {'relative_dir.relative_subdir.one.two.three'}, set()),584 (True, 'relative_dir/relative_subdir', {'one.two.three', 'qtpy.QtWidgets'}, {'relative_dir.relative_subdir.one.two.three'}, {'qtpy'}),585 (True, 'relative_dir/relative_subdir', {'one.two.three', 'pytest'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest'}),586 (True, 'relative_dir/relative_subdir', {'one.two.three', 'numpy'}, {'relative_dir.relative_subdir.one.two.three'}, {'numpy'}),587 (True, 'relative_dir/relative_subdir', {'one.two.three', 'logging', 'pytest'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest'}),588 (True, 'relative_dir/relative_subdir', {'one.two.three', 'logging', 'pytest', 'numpy'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest', 'numpy'}),589 (False, None, set(), set(), set()),590 (False, None, {'one', 'one.two.three'}, set(), {'one'}),591 (False, None, {'one', 'one.two.three', 'logging'}, set(), {'one'}),592 (False, None, {'one', 'one.two.three', 'PyQt5.QtWidgets'}, set(), {'PyQt5', 'one'}),593 (False, None, {'one', 'one.two.three', 'qtpy.QtWidgets'}, set(), {'one', 'qtpy'}),594 (False, None, {'one', 'one.two.three', 'numpy'}, set(), {'one', 'numpy'}),595 (False, None, {'one', 'one.two.three', 'pytest'}, set(), {'one', 'pytest'}),596 (False, None, {'one', 'one.two.three', 'logging', 'pytest'}, set(), {'one', 'pytest'}),597 (False, None, {'one', 'one.two.three', 'logging', 'pytest', 'PyQt5'}, set(), {'PyQt5', 'one', 'pytest'}),598 (False, None, {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, set(), {'one', 'pytest', 'numpy'}),599 (False, None, {'one'}, {'one'}, set()),600 (False, None, {'one', 'logging'}, {'one'}, set()),601 (False, None, {'one', 'PyQt5.QtWidgets'}, {'one'}, {'PyQt5'}),602 (False, None, {'one', 'qtpy.QtWidgets'}, {'one'}, {'qtpy'}),603 (False, None, {'one', 'numpy'}, {'one'}, {'numpy'}),604 (False, None, {'one', 'pytest'}, {'one'}, {'pytest'}),605 (False, None, {'one', 'logging', 'pytest'}, {'one'}, {'pytest'}),606 (False, None, {'mypkg'}, {'mypkg_metadata'}, {'mypkg'}),607 (False, None, {'mypkg'}, {'mypkg.metadata'}, set()),608 (False, None, {'one', 'one.two.three'}, {'one.two.three'}, set()),609 (False, None, {'one', 'one.two.three', 'logging'}, {'one.two.three'}, set()),610 (False, None, {'one', 'one.two.three', 'PyQt5.QtWidgets'}, {'one.two.three'}, {'PyQt5'}),611 (False, None, {'one', 'one.two.three', 'qtpy.QtWidgets'}, {'one.two.three'}, {'qtpy'}),612 (False, None, {'one', 'one.two.three', 'numpy'}, {'one.two.three'}, {'numpy'}),613 (False, None, {'one', 'one.two.three', 'pytest'}, {'one.two.three'}, {'pytest'}),614 (False, None, {'one', 'one.two.three', 'logging', 'pytest'}, {'one.two.three'}, {'pytest'}),615 (False, None, {'one.two.three'}, {'one.two.three'}, set()),616 (False, None, {'one.two.three', 'logging'}, {'one.two.three'}, set()),617 (False, None, {'one.two.three', 'PyQt5.QtWidgets'}, {'one.two.three'}, {'PyQt5'}),618 (False, None, {'one.two.three', 'qtpy.QtWidgets'}, {'one.two.three'}, {'qtpy'}),619 (False, None, {'one.two.three', 'numpy'}, {'one.two.three'}, {'numpy'}),620 (False, None, {'one.two.three', 'pytest'}, {'one.two.three'}, {'pytest'}),621 (False, None, {'one.two.three', 'logging', 'pytest'}, {'one.two.three'}, {'pytest'}),622 (False, '', set(), set(), set()),623 (False, '', {'one', 'one.two.three'}, set(), {'one'}),624 (False, '', {'one', 'one.two.three', 'logging'}, set(), {'one'}),625 (False, '', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, set(), {'PyQt5', 'one'}),626 (False, '', {'one', 'one.two.three', 'qtpy.QtWidgets'}, set(), {'one', 'qtpy'}),627 (False, '', {'one', 'one.two.three', 'pytest'}, set(), {'one', 'pytest'}),628 (False, '', {'one', 'one.two.three', 'numpy'}, set(), {'one', 'numpy'}),629 (False, '', {'one', 'one.two.three', 'logging', 'pytest'}, set(), {'one', 'pytest'}),630 (False, '', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, set(), {'one', 'pytest', 'numpy'}),631 (False, '', {'one'}, {'one'}, set()),632 (False, '', {'one', 'logging'}, {'one'}, set()),633 (False, '', {'one', 'PyQt5.QtWidgets'}, {'one'}, {'PyQt5'}),634 (False, '', {'one', 'qtpy.QtWidgets'}, {'one'}, {'qtpy'}),635 (False, '', {'one', 'numpy'}, {'one'}, {'numpy'}),636 (False, '', {'one', 'pytest'}, {'one'}, {'pytest'}),637 (False, '', {'one', 'logging', 'pytest'}, {'one'}, {'pytest'}),638 (False, '', {'one', 'logging', 'pytest', 'numpy'}, {'one'}, {'pytest', 'numpy'}),639 (False, '', {'mypkg'}, {'mypkg_metadata'}, {'mypkg'}),640 (False, '', {'mypkg'}, {'mypkg.metadata'}, set()),641 (False, '', {'one', 'one.two.three'}, {'one.two.three'}, set()),642 (False, '', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, {'one.two.three'}, {'PyQt5'}),643 (False, '', {'one', 'one.two.three', 'logging'}, {'one.two.three'}, set()),644 (False, '', {'one', 'one.two.three', 'qtpy.QtWidgets'}, {'one.two.three'}, {'qtpy'}),645 (False, '', {'one', 'one.two.three', 'numpy'}, {'one.two.three'}, {'numpy'}),646 (False, '', {'one', 'one.two.three', 'pytest'}, {'one.two.three'}, {'pytest'}),647 (False, '', {'one', 'one.two.three', 'logging', 'pytest'}, {'one.two.three'}, {'pytest'}),648 (False, '', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, {'one.two.three'}, {'pytest', 'numpy'}),649 (False, '', {'one.two.three'}, {'one.two.three'}, set()),650 (False, '', {'one.two.three', 'logging'}, {'one.two.three'}, set()),651 (False, '', {'one.two.three', 'PyQt5.QtWidgets'}, {'one.two.three'}, {'PyQt5'}),652 (False, '', {'one.two.three', 'qtpy.QtWidgets'}, {'one.two.three'}, {'qtpy'}),653 (False, '', {'one.two.three', 'pytest'}, {'one.two.three'}, {'pytest'}),654 (False, '', {'one.two.three', 'numpy'}, {'one.two.three'}, {'numpy'}),655 (False, '', {'one.two.three', 'logging', 'pytest'}, {'one.two.three'}, {'pytest'}),656 (False, '', {'one.two.three', 'logging', 'pytest', 'numpy'}, {'one.two.three'}, {'pytest', 'numpy'}),657 (False, 'relative_dir', set(), set(), set()),658 (False, 'relative_dir', {'one', 'one.two.three'}, set(), {'one'}),659 (False, 'relative_dir', {'one', 'one.two.three', 'logging'}, set(), {'one'}),660 (False, 'relative_dir', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, set(), {'PyQt5', 'one'}),661 (False, 'relative_dir', {'one', 'one.two.three', 'qtpy.QtWidgets'}, set(), {'one', 'qtpy'}),662 (False, 'relative_dir', {'one', 'one.two.three', 'pytest'}, set(), {'one', 'pytest'}),663 (False, 'relative_dir', {'one', 'one.two.three', 'logging', 'pytest'}, set(), {'one', 'pytest'}),664 (False, 'relative_dir', {'one'}, {'relative_dir.one'}, set()),665 (False, 'relative_dir', {'one', 'logging'}, {'relative_dir.one'}, set()),666 (False, 'relative_dir', {'one', 'PyQt5.QtWidgets'}, {'relative_dir.one'}, {'PyQt5'}),667 (False, 'relative_dir', {'one', 'qtpy.QtWidgets'}, {'relative_dir.one'}, {'qtpy'}),668 (False, 'relative_dir', {'one', 'pytest'}, {'relative_dir.one'}, {'pytest'}),669 (False, 'relative_dir', {'one', 'numpy'}, {'relative_dir.one'}, {'numpy'}),670 (False, 'relative_dir', {'one', 'logging', 'pytest'}, {'relative_dir.one'}, {'pytest'}),671 (False, 'relative_dir', {'one', 'logging', 'pytest', 'numpy'}, {'relative_dir.one'}, {'pytest', 'numpy'}),672 (False, 'relative_dir', {'mypkg'}, {'relative_dir.mypkg_metadata'}, {'mypkg'}),673 (False, 'relative_dir', {'mypkg'}, {'relative_dir.mypkg.metadata'}, set()),674 (False, 'relative_dir', {'one', 'one.two.three'}, {'relative_dir.one.two.three'}, set()),675 (False, 'relative_dir', {'one', 'one.two.three', 'logging'}, {'relative_dir.one.two.three'}, set()),676 (False, 'relative_dir', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, {'relative_dir.one.two.three'}, {'PyQt5'}),677 (False, 'relative_dir', {'one', 'one.two.three', 'qtpy.QtWidgets'}, {'relative_dir.one.two.three'}, {'qtpy'}),678 (False, 'relative_dir', {'one', 'one.two.three', 'pytest'}, {'relative_dir.one.two.three'}, {'pytest'}),679 (False, 'relative_dir', {'one', 'one.two.three', 'numpy'}, {'relative_dir.one.two.three'}, {'numpy'}),680 (False, 'relative_dir', {'one', 'one.two.three', 'logging', 'pytest'}, {'relative_dir.one.two.three'}, {'pytest'}),681 (False, 'relative_dir', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, {'relative_dir.one.two.three'}, {'pytest', 'numpy'}),682 (False, 'relative_dir', {'one.two.three'}, {'relative_dir.one.two.three'}, set()),683 (False, 'relative_dir', {'one.two.three', 'logging'}, {'relative_dir.one.two.three'}, set()),684 (False, 'relative_dir', {'one.two.three', 'PyQt5.QtWidgets'}, {'relative_dir.one.two.three'}, {'PyQt5'}),685 (False, 'relative_dir', {'one.two.three', 'qtpy.QtWidgets'}, {'relative_dir.one.two.three'}, {'qtpy'}),686 (False, 'relative_dir', {'one.two.three', 'pytest'}, {'relative_dir.one.two.three'}, {'pytest'}),687 (False, 'relative_dir', {'one.two.three', 'numpy'}, {'relative_dir.one.two.three'}, {'numpy'}),688 (False, 'relative_dir', {'one.two.three', 'logging', 'pytest'}, {'relative_dir.one.two.three'}, {'pytest'}),689 (False, 'relative_dir', {'one.two.three', 'logging', 'pytest', 'numpy'}, {'relative_dir.one.two.three'}, {'pytest', 'numpy'}),690 (False, 'relative_dir/relative_subdir', set(), set(), set()),691 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three'}, set(), {'one'}),692 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging'}, set(), {'one'}),693 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, set(), {'PyQt5', 'one'}),694 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'qtpy.QtWidgets'}, set(), {'one', 'qtpy'}),695 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'pytest'}, set(), {'one', 'pytest'}),696 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'numpy'}, set(), {'one', 'numpy'}),697 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging', 'pytest'}, set(), {'one', 'pytest'}),698 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, set(), {'one', 'pytest', 'numpy'}),699 (False, 'relative_dir/relative_subdir', {'one'}, {'relative_dir.relative_subdir.one'}, set()),700 (False, 'relative_dir/relative_subdir', {'one', 'logging'}, {'relative_dir.relative_subdir.one'}, set()),701 (False, 'relative_dir/relative_subdir', {'one', 'PyQt5.QtWidgets'}, {'relative_dir.relative_subdir.one'}, {'PyQt5'}),702 (False, 'relative_dir/relative_subdir', {'one', 'qtpy.QtWidgets'}, {'relative_dir.relative_subdir.one'}, {'qtpy'}),703 (False, 'relative_dir/relative_subdir', {'one', 'pytest'}, {'relative_dir.relative_subdir.one'}, {'pytest'}),704 (False, 'relative_dir/relative_subdir', {'one', 'numpy'}, {'relative_dir.relative_subdir.one'}, {'numpy'}),705 (False, 'relative_dir/relative_subdir', {'one', 'logging', 'pytest'}, {'relative_dir.relative_subdir.one'}, {'pytest'}),706 (False, 'relative_dir/relative_subdir', {'one', 'logging', 'pytest', 'numpy'}, {'relative_dir.relative_subdir.one'}, {'pytest', 'numpy'}),707 (False, 'relative_dir/relative_subdir', {'mypkg'}, {'relative_dir.relative_subdir.mypkg_metadata'}, {'mypkg'}),708 (False, 'relative_dir/relative_subdir', {'mypkg'}, {'relative_dir.relative_subdir.mypkg.metadata'}, set()),709 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three'}, {'relative_dir.relative_subdir.one.two.three'}, set()),710 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging'}, {'relative_dir.relative_subdir.one.two.three'}, set()),711 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'PyQt5.QtWidgets'}, {'relative_dir.relative_subdir.one.two.three'}, {'PyQt5'}),712 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'qtpy.QtWidgets'}, {'relative_dir.relative_subdir.one.two.three'}, {'qtpy'}),713 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'pytest'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest'}),714 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'numpy'}, {'relative_dir.relative_subdir.one.two.three'}, {'numpy'}),715 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging', 'pytest'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest'}),716 (False, 'relative_dir/relative_subdir', {'one', 'one.two.three', 'logging', 'pytest', 'numpy'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest', 'numpy'}),717 (False, 'relative_dir/relative_subdir', {'one.two.three'}, {'relative_dir.relative_subdir.one.two.three'}, set()),718 (False, 'relative_dir/relative_subdir', {'one.two.three', 'logging'}, {'relative_dir.relative_subdir.one.two.three'}, set()),719 (False, 'relative_dir/relative_subdir', {'one.two.three', 'PyQt5.QtWidgets'}, {'relative_dir.relative_subdir.one.two.three'}, {'PyQt5'}),720 (False, 'relative_dir/relative_subdir', {'one.two.three', 'qtpy.QtWidgets'}, {'relative_dir.relative_subdir.one.two.three'}, {'qtpy'}),721 (False, 'relative_dir/relative_subdir', {'one.two.three', 'pytest'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest'}),722 (False, 'relative_dir/relative_subdir', {'one.two.three', 'numpy'}, {'relative_dir.relative_subdir.one.two.three'}, {'numpy'}),723 (False, 'relative_dir/relative_subdir', {'one.two.three', 'logging', 'pytest'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest'}),724 (False, 'relative_dir/relative_subdir', {'one.two.three', 'logging', 'pytest', 'numpy'}, {'relative_dir.relative_subdir.one.two.three'}, {'pytest', 'numpy'}),725])726def test_normalize_imports(found_imports, local_modules, expected_results, relative_loc, acc_py_active, ensure_acc_py):727 ensure_acc_py(acc_py_active)728 used_imports = {ScannedImport.create(pkg=i, relative_loc=relative_loc) for i in found_imports}729 assert normalize_imports(used_imports, local_modules) == expected_results730@pytest.mark.parametrize('acc_py_active,file_contents,expected_imports', [731 (True, [], set()),732 (False, [], set()),733 (True, [('example.py', '')], set()),734 (False, [('example.py', '')], set()),735 (True, [('example.ui', """<ui version="4.0">736 <widget class="QLabel" name="CLabel">737 <property name="text" stdset="0">738 <string>test</string>739 </property>740 </widget>741</ui>""")], set()),742 (False, [('example.ui', """<ui version="4.0">743 <widget class="QLabel" name="CLabel">744 <property name="text" stdset="0">745 <string>test</string>746 </property>747 </widget>748</ui>""")], set()),749 (True, [('example.py', 'import logging')], set()),750 (False, [('example.py', 'import logging')], set()),751 (True, [('example.py', 'from accwidgets.lsa_selector import LsaSelector')], {'accwidgets'}),752 (False, [('example.py', 'from accwidgets.lsa_selector import LsaSelector')], {'accwidgets'}),753 (True, [('logs.py', 'import logging'), ('example.py', 'from accwidgets.lsa_selector import LsaSelector')], {'accwidgets'}),754 (False, [('logs.py', 'import logging'), ('example.py', 'from accwidgets.lsa_selector import LsaSelector')], {'accwidgets'}),755 (True, [('example.ui', """<?xml version="1.0" encoding="UTF-8"?>756<ui version="4.0">757 <class>Form</class>758 <widget class="CLabel" name="CLabel">759 <property name="snippetFilename" stdset="0">760 <string>logs.py</string>761 </property>762 </widget>763</ui>"""), ('logs.py', 'import logging')], set()),764 (False, [('example.ui', """<?xml version="1.0" encoding="UTF-8"?>765<ui version="4.0">766 <class>Form</class>767 <widget class="CLabel" name="CLabel">768 <property name="snippetFilename" stdset="0">769 <string>logs.py</string>770 </property>771 </widget>772</ui>"""), ('logs.py', 'import logging')], set()),773 (True, [('example.ui', """<?xml version="1.0" encoding="UTF-8"?>774<ui version="4.0">775 <widget class="CLabel" name="CLabel">776 <property name="snippetFilename" stdset="0">777 <string>example.py</string>778 </property>779 </widget>780</ui>"""), ('example.py', 'from accwidgets.lsa_selector import LsaSelector')], {'accwidgets'}),781 (False, [('example.ui', """<?xml version="1.0" encoding="UTF-8"?>782<ui version="4.0">783 <widget class="CLabel" name="CLabel">784 <property name="snippetFilename" stdset="0">785 <string>example.py</string>786 </property>787 </widget>788</ui>"""), ('example.py', 'from accwidgets.lsa_selector import LsaSelector')], {'accwidgets'}),789 (True, [('app.py', """from comrad import CDisplay790class MyDisplay(CDisplay):791 def ui_filename(self):792 return 'app.ui'793"""), ('app.ui', """<?xml version="1.0" encoding="UTF-8"?>794<ui version="4.0">795 <class>Form</class>796 <widget class="QWidget" name="Form">797 <layout class="QHBoxLayout" name="horizontalLayout">798 <item>799 <widget class="CLabel" name="CLabel">800 <property name="channel" stdset="0">801 <string notr="true">DemoDevice/Acquisition#Demo</string>802 </property>803 <property name="valueTransformation">804 <string notr="true">import numpy as np; from PyQt5.QtCore import QObject; output(np.array([1, 2]))</string>805 </property>806 </widget>807 </item>808 </layout>809 </widget>810 <customwidgets>811 <customwidget>812 <class>PyDMLabel</class>813 <extends>QLabel</extends>814 <header>pydm.widgets.label</header>815 </customwidget>816 <customwidget>817 <class>CLabel</class>818 <extends>PyDMLabel</extends>819 <header>comrad.widgets.indicators</header>820 </customwidget>821 </customwidgets>822 <resources/>823 <connections/>824</ui>""")], {'comrad', 'numpy', 'pydm'}),825 (False, [('app.py', """from comrad import CDisplay826class MyDisplay(CDisplay):827 def ui_filename(self):828 return 'app.ui'829"""), ('app.ui', """<?xml version="1.0" encoding="UTF-8"?>830<ui version="4.0">831 <class>Form</class>832 <widget class="QWidget" name="Form">833 <layout class="QHBoxLayout" name="horizontalLayout">834 <item>835 <widget class="CLabel" name="CLabel">836 <property name="channel" stdset="0">837 <string notr="true">DemoDevice/Acquisition#Demo</string>838 </property>839 <property name="valueTransformation">840 <string notr="true">import numpy as np; from PyQt5.QtCore import QObject; output(np.array([1, 2]))</string>841 </property>842 </widget>843 </item>844 </layout>845 </widget>846 <customwidgets>847 <customwidget>848 <class>PyDMLabel</class>849 <extends>QLabel</extends>850 <header>pydm.widgets.label</header>851 </customwidget>852 <customwidget>853 <class>CLabel</class>854 <extends>PyDMLabel</extends>855 <header>comrad.widgets.indicators</header>856 </customwidget>857 </customwidgets>858 <resources/>859 <connections/>860</ui>""")], {'comrad', 'numpy', 'pydm', 'PyQt5'}),861])862def test_scan_imports_succeeds(tmp_path: Path, expected_imports, file_contents, acc_py_active, ensure_acc_py):863 ensure_acc_py(acc_py_active)864 for filename, content in file_contents:865 (tmp_path / filename).write_text(content)866 actual_results = scan_imports(directory=tmp_path)867 assert actual_results == expected_imports868@pytest.mark.parametrize('file_contents,expected_imports,expected_warnings', [869 ([('example.py', 'import')], set(), {'{dir}/example.py contains invalid Python syntax: invalid syntax (<unknown>, line 1)'}),870 ([('example.ui', """<ui version="4.0">871 <widget class="QLabel" name="CLabel">872 <property name="text" stdset="0">873 <string>test</string>874</ui>""")], set(), {'{dir}/example.ui cannot be parsed as XML: mismatched tag: line 5, column 2'}),875 ([('example.py', 'import logging'), ('example2.py', 'import')], set(), {'{dir}/example2.py contains invalid Python syntax: invalid syntax (<unknown>, line 1)'}),876 ([('example.py', 'from accwidgets.lsa_selector import LsaSelector'), ('example2.py', 'import')], {'accwidgets'}, {'{dir}/example2.py contains invalid Python syntax: invalid syntax (<unknown>, line 1)'}),877 ([('example.py', 'import'), ('example2.py', 'import')], set(), {'{dir}/example.py contains invalid Python syntax: invalid syntax (<unknown>, line 1)',878 '{dir}/example2.py contains invalid Python syntax: invalid syntax (<unknown>, line 1)'}),879 ([('example.ui', """<?xml version="1.0" encoding="UTF-8"?>880<ui version="4.0">881 <class>Form</class>882 <widget class="CLabel" name="CLabel">883 <property name="snippetFilename" stdset="0">884 <string>example.py</string>885 </property>886 </widget>887</ui>"""), ('example.py', 'import; import numpy')], set(), {'{dir}/example.py contains invalid Python syntax: invalid syntax (<unknown>, line 1)',888 "Indicated file example.py inside {dir}/example.ui's snippetFilename contains invalid Python syntax: invalid syntax (<unknown>, line 1)"}),889 ([('example.ui', """<?xml version="1.0" encoding="UTF-8"?>890<ui version="4.0">891 <class>Form</class>892 <widget class="CLabel" name="CLabel">893 <property name="snippetFilename" stdset="0">894 <string>example.py</string>895 </property>896 </widget>897</ui>""")], set(), {"Indicated file example.py inside {dir}/example.ui's snippetFilename cannot be opened"}),898 ([('app.py', """from comrad import CDisplay899class MyDisplay(CDisplay):900 def ui_filename(self):901 return 'app.ui'902"""), ('app.ui', """<?xml version="1.0" encoding="UTF-8"?>903<ui version="4.0">904 <class>Form</class>905 <widget class="QWidget" name="Form">906 <layout class="QHBoxLayout" name="horizontalLayout">907 <item>908 <widget class="CLabel" name="CLabel">909 <property name="channel" stdset="0">910 <string notr="true">DemoDevice/Acquisition#Demo</string>911 </property>912 <property name="valueTransformation">913 <string notr="true">import; import numpy</string>914 </property>915 </widget>916 </item>917 </layout>918 </widget>919 <customwidgets>920 <customwidget>921 <class>PyDMLabel</class>922 <extends>QLabel</extends>923 <header>pydm.widgets.label</header>924 </customwidget>925 <customwidget>926 <class>CLabel</class>927 <extends>PyDMLabel</extends>928 <header>comrad.widgets.indicators</header>929 </customwidget>930 </customwidgets>931 <resources/>932 <connections/>933</ui>""")], {'comrad', 'pydm'}, {'valueTransformation "import; import numpy" inside {dir}/app.ui contains invalid Python syntax: invalid syntax (<unknown>, line 1)'}),934])935def test_scan_imports_fails(tmp_path: Path, expected_imports, expected_warnings, file_contents, log_capture):936 for filename, content in file_contents:937 (tmp_path / filename).write_text(content)938 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == []939 actual_results = scan_imports(directory=tmp_path)940 assert actual_results == expected_imports941 assert set(log_capture(logging.WARNING, '_comrad.package.import_scanning')) == {w.format(dir=str(tmp_path)) for w in expected_warnings}942all_examples = examples.find_runnable()943@pytest.mark.parametrize('example_path', all_examples, ids=list(map(str, all_examples)))944def test_scan_imports_smoke_test(example_path, log_capture):945 # This test verifies that all existing comrad examples can be parsed without warnings (skipping imports)946 assert log_capture(logging.WARNING, '_comrad.package.import_scanning') == []947 scan_imports(directory=example_path)...
locate_remote_file_test_alone.py
Source:locate_remote_file_test_alone.py
1# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14import shutil15import unittest16import parl17import os18import sys19import time20import threading21from six.moves import queue22from parl.remote.master import Master23from parl.remote.worker import Worker24from parl.remote.client import disconnect25from parl.remote import exceptions26from parl.utils import logger, get_free_tcp_port27class TestCluster(unittest.TestCase):28 def tearDown(self):29 disconnect()30 def _write_remote_actor_to_file(self, file_path):31 with open(file_path, 'w') as f:32 f.write('''\33import parl34@parl.remote_class35class Actor(object):36 def __init__(self):37 pass38 39 def add_one(self, x):40 return x + 141''')42 def _gen_remote_class_in_absolute_path(self, file_name):43 # E.g.: /A/B/C/test.py44 cur_dir = os.getcwd() # /A/B/C45 parent_dir = os.path.split(cur_dir)[0] # /A/B46 # /A/B/parl_unittest_abs_dir47 abs_dir = os.path.join(parent_dir,48 "parl_unittest_abs_dir_{}".format(time.time()))49 if os.path.exists(abs_dir):50 logger.warning("removing directory: {}".format(abs_dir))51 shutil.rmtree(abs_dir)52 os.mkdir(abs_dir)53 file_path = os.path.join(abs_dir, file_name)54 self._write_remote_actor_to_file(file_path)55 logger.info("create file: {}".format(file_path))56 return abs_dir57 def _gen_remote_class_in_relative_path(self, file_name):58 relative_dir = "../parl_unittest_relative_dir_{}".format(time.time())59 if os.path.exists(relative_dir):60 logger.warning("removing directory: {}".format(relative_dir))61 shutil.rmtree(relative_dir)62 os.mkdir(relative_dir)63 file_path = os.path.join(relative_dir, file_name)64 self._write_remote_actor_to_file(file_path)65 logger.info("create file: {}".format(file_path))66 return relative_dir67 def test_locate_remote_file_with_absolute_env_path(self):68 port = get_free_tcp_port()69 master = Master(port=port)70 th = threading.Thread(target=master.run)71 th.start()72 time.sleep(3)73 worker1 = Worker('localhost:{}'.format(port), 1)74 for _ in range(3):75 if master.cpu_num == 1:76 break77 time.sleep(10)78 self.assertEqual(1, master.cpu_num)79 parl.connect('localhost:{}'.format(port))80 abs_dir = self._gen_remote_class_in_absolute_path("abs_actor.py")81 sys.path.append(abs_dir) # add absolute environment path82 import abs_actor83 actor = abs_actor.Actor()84 self.assertEqual(actor.add_one(1), 2)85 shutil.rmtree(abs_dir)86 sys.path.remove(abs_dir)87 master.exit()88 worker1.exit()89 def test_locate_remote_file_with_absolute_env_path_in_multi_threads(self):90 port = get_free_tcp_port()91 master = Master(port=port)92 th = threading.Thread(target=master.run)93 th.start()94 time.sleep(3)95 worker1 = Worker('localhost:{}'.format(port), 10)96 for _ in range(3):97 if master.cpu_num == 10:98 break99 time.sleep(10)100 self.assertEqual(10, master.cpu_num)101 parl.connect('localhost:{}'.format(port))102 abs_dir = self._gen_remote_class_in_absolute_path("abs_actor2.py")103 sys.path.append(abs_dir) # add absolute environment path104 import abs_actor2105 def run(q):106 try:107 actor = abs_actor2.Actor()108 self.assertEqual(actor.add_one(1), 2)109 except Exception as e:110 q.put(False)111 raise e112 q.put(True)113 result = queue.Queue()114 threads = []115 for _ in range(10):116 th = threading.Thread(target=run, args=(result, ))117 th.start()118 threads.append(th)119 for th in threads:120 th.join()121 no_exception = result.get()122 assert no_exception123 shutil.rmtree(abs_dir)124 sys.path.remove(abs_dir)125 master.exit()126 worker1.exit()127 def test_locate_remote_file_with_relative_env_path_without_distributing_files(128 self):129 port = get_free_tcp_port()130 master = Master(port=port)131 th = threading.Thread(target=master.run)132 th.start()133 time.sleep(3)134 worker1 = Worker('localhost:{}'.format(port), 1)135 for _ in range(3):136 if master.cpu_num == 1:137 break138 time.sleep(10)139 self.assertEqual(1, master.cpu_num)140 relative_dir = self._gen_remote_class_in_relative_path(141 "relative_actor1.py")142 parl.connect('localhost:{}'.format(port))143 sys.path.append(relative_dir) # add relative environment path144 import relative_actor1145 with self.assertRaises(exceptions.RemoteError):146 actor = relative_actor1.Actor()147 shutil.rmtree(relative_dir)148 sys.path.remove(relative_dir)149 master.exit()150 worker1.exit()151 def test_locate_remote_file_with_relative_env_path_with_distributing_files(152 self):153 port = get_free_tcp_port()154 master = Master(port=port)155 th = threading.Thread(target=master.run)156 th.start()157 time.sleep(3)158 worker1 = Worker('localhost:{}'.format(port), 1)159 for _ in range(3):160 if master.cpu_num == 1:161 break162 time.sleep(10)163 self.assertEqual(1, master.cpu_num)164 relative_dir = self._gen_remote_class_in_relative_path(165 "relative_actor2.py")166 parl.connect(167 'localhost:{}'.format(port),168 distributed_files=["{}/*".format(relative_dir)])169 sys.path.append(relative_dir) # add relative environment path170 import relative_actor2171 actor = relative_actor2.Actor()172 self.assertEqual(actor.add_one(1), 2)173 shutil.rmtree(relative_dir)174 sys.path.remove(relative_dir)175 master.exit()176 worker1.exit()177if __name__ == '__main__':...
run.py
Source:run.py
1'''2Created on Dec 12, 20183@author: DPain4'''5import sys6import os7import shutil8WORKSPACE_NAME = "LOSTARK"9ctr = 010"""11How to run:12python run.py "D:\Games\Games\LOSTARK" "C:\LOSTARK1.0.3.4,46.md5" "C:\LOSTARK1.1.0.2,91.md5"13"""14def main():15 global ctr16 if len(sys.argv) != 4:17 print("Incorrect number of parameters!")18 exit(1)19 game_dir = sys.argv[1]20 old_checksum_dir = sys.argv[2]21 new_checksum_dir = sys.argv[3]22 if game_dir[-1] in ["/", "\\"]:23 game_dir = game_dir[:-1]24 print("Removed trailing slash from game directory")25 print("LOSTARK directory: %s" % game_dir)26 print("MD5 checksum directory: %s" % old_checksum_dir)27 if not os.path.exists(old_checksum_dir):28 print("MD5 checksum file does not exist: %s" % old_checksum_dir)29 exit(1)30 if not os.path.exists(new_checksum_dir):31 print("MD5 checksum file does not exist: %s" % new_checksum_dir)32 exit(1)33 try:34 # Create folder where updated files will go to35 os.mkdir(WORKSPACE_NAME)36 except FileExistsError:37 print(WORKSPACE_NAME + " folder already exists")38 old_hash = dict()39 missing_files = list()40 # Storing MD5s of old version41 with open(old_checksum_dir, 'r') as file:42 first_line = file.readline()43 print(first_line)44 index = first_line.find("LOSTARK") + len("LOSTARK")45 if index < 34:46 # 34 = len(32bit MD5 hash) + len(" *")47 print("Possibly a corrupted MD5 hash file from hashcheck!")48 exit(1)49 file.seek(0)50 for line in file:51 hash_val = line[:32]52 relative_dir = line[index:-1]53 print(hash_val, relative_dir)54 old_hash[relative_dir] = hash_val.lower()55 # Reading new version's MD5s and copying files56 with open(new_checksum_dir, 'r') as file:57 first_line = file.readline()58 print(first_line)59 index = first_line.find("LOSTARK") + len("LOSTARK")60 if index < 34:61 # 34 = len(32bit MD5 hash) + len(" *")62 print("Possibly a corrupted MD5 hash file from hashcheck!")63 exit(1)64 file.seek(0)65 for line in file:66 hash_val = line[:32].lower()67 relative_dir = line[index:-1]68 print(hash_val, relative_dir)69 old_val = old_hash.get(relative_dir)70 if old_val is None or hash_val != old_val:71 if os.path.exists(game_dir + relative_dir):72 ctr += 173 print("Copied file: " + os.path.basename(relative_dir))74 copy_file(game_dir, relative_dir)75 else:76 missing_files.append(relative_dir)77 print("You do not have a file the new MD5 report has!")78 print("Copied over %d files!" % ctr)79 print("Missing files: \n%s" % str(missing_files))80def copy_file(game_dir, relative_dir):81 os.makedirs(os.path.dirname(WORKSPACE_NAME + relative_dir), exist_ok=True)82 shutil.copy2(os.path.abspath(game_dir + relative_dir),83 os.path.abspath(WORKSPACE_NAME + relative_dir))...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!