示例#1
0
def custom_zw():
    zw = web.share_mode.ZipWriter(
        common.Common(),
        zip_filename=common.Common.random_string(4, 6),
        processed_size_callback=lambda _: "custom_callback",
    )
    yield zw
    zw.close()
    os.remove(zw.zip_filename)
示例#2
0
def default_zw():
    zw = web.share_mode.ZipWriter(common.Common())
    yield zw
    zw.close()
    tmp_dir = os.path.dirname(zw.zip_filename)
    try:
        shutil.rmtree(tmp_dir, ignore_errors=True)
    except:
        pass
示例#3
0
def settings_obj(sys_onionshare_dev_mode, platform_linux):
    _common = common.Common()
    _common.version = 'DUMMY_VERSION_1.2.3'
    return settings.Settings(_common)
示例#4
0
 def test_filename_windows(self, monkeypatch, platform_windows):
     monkeypatch.setenv('APPDATA', 'C:')
     obj = settings.Settings(common.Common())
     assert obj.filename.replace('/',
                                 '\\') == 'C:\\OnionShare\\onionshare.json'
示例#5
0
 def test_filename_linux(self, monkeypatch, os_path_expanduser,
                         platform_linux):
     obj = settings.Settings(common.Common())
     assert obj.filename == '~/.config/onionshare/onionshare.json'
示例#6
0
 def test_filename_darwin(self, monkeypatch, os_path_expanduser,
                          platform_darwin):
     obj = settings.Settings(common.Common())
     assert (obj.filename ==
             '~/Library/Application Support/OnionShare/onionshare.json')
示例#7
0
 def test_filename_windows(self, monkeypatch, platform_windows):
     obj = settings.Settings(common.Common())
     assert obj.filename == os.path.expanduser(
         "~\\AppData\\Roaming\\OnionShare-testdata\\onionshare.json")
示例#8
0
 def test_filename_linux(self, monkeypatch, platform_linux):
     obj = settings.Settings(common.Common())
     assert obj.filename == os.path.expanduser(
         "~/.config/onionshare-testdata/onionshare.json")
示例#9
0
 def test_filename_darwin(self, monkeypatch, platform_darwin):
     obj = settings.Settings(common.Common())
     assert obj.filename == os.path.expanduser(
         "~/Library/Application Support/OnionShare-testdata/onionshare.json"
     )
示例#10
0
def common_obj():
    return common.Common()
示例#11
0
def default_zw():
    zw = web.share_mode.ZipWriter(common.Common())
    yield zw
    zw.close()
    tmp_dir = os.path.dirname(zw.zip_filename)
    shutil.rmtree(tmp_dir)
 def test_filename_windows(self, monkeypatch, platform_windows):
     monkeypatch.setenv("APPDATA", "C:")
     obj = settings.Settings(common.Common())
     assert obj.filename.replace("/",
                                 "\\") == "C:\\OnionShare\\onionshare.json"