def tearDownClass(cls): gc.collect() cls.app.setApplicationName(cls.__appname) cls.app.setOrganizationDomain(cls.__appdomain) cls.app = None super(QCoreAppTestCase, cls).tearDownClass() QStandardPaths.setTestModeEnabled(False)
def tearDownClass(cls): gc.collect() cls.app.setApplicationName(cls.__appname) cls.app.setOrganizationDomain(cls.__appdomain) cls.app.sendPostedEvents(None, 0) # Keep app instance alive between tests with PyQt5 5.14.0 and later if PYQT_VERSION <= 0x050e00: cls.app = None super(QCoreAppTestCase, cls).tearDownClass() QStandardPaths.setTestModeEnabled(False)
def setUpClass(cls): super(QCoreAppTestCase, cls).setUpClass() QStandardPaths.setTestModeEnabled(True) app = cls._AppClass.instance() if app is None: app = cls._AppClass([]) cls.app = app cls.__appname = cls.app.applicationName() cls.__appdomain = cls.app.organizationDomain() cls.app.setApplicationName("orangecanvas.testing") cls.app.setOrganizationDomain("biolab.si")
def _session(cachedir=None): # type: (...) -> requests.Session """ Return a requests.Session instance Parameters ---------- cachedir : Optional[str] HTTP cache location. Returns ------- session : requests.Session """ import cachecontrol.caches if cachedir is None: cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation) cachedir = os.path.join(cachedir, "networkcache", "requests") session = requests.Session() session = cachecontrol.CacheControl( session, cache=cachecontrol.caches.FileCache( directory=cachedir ) ) return session
def data_dir_base(): """ Return the platform dependent generic application directory. This is usually - on windows: "%USERPROFILE%\\AppData\\Local\\" - on OSX: "~/Library/Application Support/" - other: "~/.local/share/ """ return QStandardPaths.writableLocation(QStandardPaths.GenericDataLocation)
def cache_dir(): """ Return the application cache directory. If the directory path does not yet exists then create it. """ init() cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation) version = QCoreApplication.applicationVersion() cachedir = os.path.join(cachedir, version) if not os.path.exists(cachedir): os.makedirs(cachedir) return cachedir
def data_dir(): """ Return the application data directory. If the directory path does not yet exists then create it. """ init() datadir = QStandardPaths.writableLocation(QStandardPaths.DataLocation) version = QCoreApplication.applicationVersion() datadir = os.path.join(datadir, version) if not os.path.isdir(datadir): try: os.makedirs(datadir, exist_ok=True) except OSError: pass return datadir
def cache_dir(): """Return the application cache directory. If the directory path does not yet exists then create it. """ warnings.warn(f"'{__name__}.cache_dir' is deprecated.", DeprecationWarning, stacklevel=2) base = QStandardPaths.writableLocation(QStandardPaths.GenericCacheLocation) name = QCoreApplication.applicationName() version = QCoreApplication.applicationVersion() if not name: name = "Orange" if not version: version = "0.0.0" path = os.path.join(base, name, version) try: os.makedirs(path, exist_ok=True) except OSError: pass return path
def standard_location(type): warnings.warn("Use QStandardPaths.writableLocation", DeprecationWarning, stacklevel=2) return QStandardPaths.writableLocation(type)
def standard_location(type): warnings.warn( "Use QStandardPaths.writableLocation", DeprecationWarning, stacklevel=2 ) return QStandardPaths.writableLocation(type)
def setUp(self) -> None: super().setUp() QStandardPaths.setTestModeEnabled(True) QSettings.setDefaultFormat(QSettings.IniFormat)
def tearDown(self) -> None: QStandardPaths.setTestModeEnabled(False) QSettings.setDefaultFormat(QSettings.NativeFormat) super().tearDown()
def standard_location(type): return QStandardPaths.writableLocation(type)