From 6c63e474430d49be675f1af94c259eb5f300c650 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 9 Oct 2020 10:03:39 +0530 Subject: [PATCH] Remove unused code --- src/calibre/startup.py | 53 ------------------------------------------ 1 file changed, 53 deletions(-) diff --git a/src/calibre/startup.py b/src/calibre/startup.py index 731afff32f..64597e7b0e 100644 --- a/src/calibre/startup.py +++ b/src/calibre/startup.py @@ -221,56 +221,3 @@ if not _run_once: except Exception: pass # Don't care about failure to set name threading.Thread.start = new_start - - -def test_lopen(): - from calibre.ptempfile import TemporaryDirectory - from calibre import CurrentDir - n = 'f\xe4llen' - print('testing lopen()') - - if iswindows: - import msvcrt, win32api - - def assert_not_inheritable(f): - if win32api.GetHandleInformation(msvcrt.get_osfhandle(f.fileno())) & 0b1: - raise SystemExit('File handle is inheritable!') - else: - import fcntl - - def assert_not_inheritable(f): - if not fcntl.fcntl(f, fcntl.F_GETFD) & fcntl.FD_CLOEXEC: - raise SystemExit('File handle is inheritable!') - - def copen(*args): - ans = lopen(*args) - assert_not_inheritable(ans) - return ans - - with TemporaryDirectory() as tdir, CurrentDir(tdir): - with copen(n, 'w') as f: - f.write('one') - - print('O_CREAT tested') - with copen(n, 'w+b') as f: - f.write(b'two') - with copen(n, 'r') as f: - if f.read() == 'two': - print('O_TRUNC tested') - else: - raise Exception('O_TRUNC failed') - with copen(n, 'ab') as f: - f.write(b'three') - with copen(n, 'r+') as f: - if f.read() == 'twothree': - print('O_APPEND tested') - else: - raise Exception('O_APPEND failed') - with copen(n, 'r+') as f: - f.seek(3) - f.write('xxxxx') - f.seek(0) - if f.read() == 'twoxxxxx': - print('O_RANDOM tested') - else: - raise Exception('O_RANDOM failed')