本文整理汇总了Python中core.osutils.file.File.replace方法的典型用法代码示例。如果您正苦于以下问题:Python File.replace方法的具体用法?Python File.replace怎么用?Python File.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.osutils.file.File
的用法示例。
在下文中一共展示了File.replace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_330_tns_run_ios_after_rebuild_of_native_project
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import replace [as 别名]
def test_330_tns_run_ios_after_rebuild_of_native_project(self):
"""
`tns run ios` should work properly after rebuild of native project (test for issue #2860)
"""
# `tns run ios` and wait until app is deployed
log = Tns.run_ios(attributes={'--path': self.app_name, '--device': self.DEVICE_ID}, wait=False,
assert_success=False, log_trace=True)
strings = [self.DEVICE_ID, 'Successfully synced application']
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10)
# Verify app is running
assert Device.wait_for_text(device_id=self.DEVICE_ID, text="Tap the button"), "App failed to load!"
# Update native project
config_path = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'build.xcconfig')
File.replace(file_path=config_path, str1='More info', str2='If you need more info')
strings = ['ARCHIVE SUCCEEDED', 'Successfully synced application', self.DEVICE_ID, 'CONSOLE LOG']
not_existing_strings = ['Unable to sync files', 'Multiple errors were thrown']
Tns.wait_for_log(log_file=log, string_list=strings, not_existing_string_list=not_existing_strings, timeout=120)
# Verify app is running
assert Device.wait_for_text(device_id=self.DEVICE_ID, text="Tap the button"), "App failed to load!"
# Change JS and wait until app is synced
ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS, sleep=10)
strings = ['Successfully transferred', 'main-view-model.js', 'Successfully synced application', self.DEVICE_ID]
Tns.wait_for_log(log_file=log, string_list=strings)
assert Device.wait_for_text(device_id=self.DEVICE_ID, text="clicks"), "JS changes not synced on device!"
# Rollback all the changes and verify files are synced
ReplaceHelper.rollback(self.app_name, ReplaceHelper.CHANGE_JS, sleep=10)
strings = ['Successfully transferred', 'main-view-model.js', 'Restarting application']
Tns.wait_for_log(log_file=log, string_list=strings)
assert Device.wait_for_text(device_id=self.DEVICE_ID, text="taps left"), "JS changes not synced on device!"
示例2: test_330_prepare_android_next
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import replace [as 别名]
def test_330_prepare_android_next(self):
Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False)
Tns.platform_add_android(attributes={"--path": self.app_name}, version="next")
Folder.cleanup(os.path.join(self.app_name, "node_modules"))
Folder.cleanup(os.path.join(self.app_name, "platforms"))
android_version = Npm.get_version("[email protected]")
File.replace(file_path=os.path.join(self.app_name, "package.json"), str1=android_version, str2="next")
output = Tns.prepare_android(attributes={"--path": self.app_name})
TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.FIRST_TIME)
示例3: test_401_plugin_add_sandbox_pod_can_not_write_outside_app_folder_if_use_pod_sandbox_is_true
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import replace [as 别名]
def test_401_plugin_add_sandbox_pod_can_not_write_outside_app_folder_if_use_pod_sandbox_is_true(self):
File.replace("node_modules/nativescript/config/config.json", '"USE_POD_SANDBOX": false',
'"USE_POD_SANDBOX": true')
Tns.create_app(self.app_name)
Tns.platform_add_ios(attributes={"--path": self.app_name, "--frameworkPath": IOS_PACKAGE})
plugin = os.path.join(TEST_RUN_HOME, "data", "CocoaPods", "nativescript-ios-fail-with-sandbox-plugin.tgz")
output = Tns.plugin_add(plugin, attributes={"--path": self.app_name}, assert_success=False)
assert "Successfully installed plugin nativescript-ios-fail-with-sandbox-plugin." in output
assert "nativescript-ios-fail-with-sandbox-plugin" in File.read(self.app_name + "/package.json")
output = Tns.prepare_ios(attributes={"--path": self.app_name}, assert_success=False)
assert "Successfully prepared " + \
"plugin nativescript-ios-fail-with-sandbox-plugin for ios." in output
assert "sh: ../I_MADE_THIS_FILE.txt: Operation not permitted" in output
assert not File.exists(self.app_name + "/platforms/I_MADE_THIS_FILE.txt")
示例4: rollback
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import replace [as 别名]
def rollback(app_name, file_change, sleep=1):
File.replace(app_name + '/' + file_change[0], file_change[2], file_change[1])
time.sleep(sleep)
示例5: tearDown
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import replace [as 别名]
def tearDown(self):
File.replace(TEST_RUN_HOME + "/node_modules/nativescript/config/config.json", '"USE_POD_SANDBOX": true',
'"USE_POD_SANDBOX": false')